Home - Programming - "Multiple-step operation generated errors"

PROBLEM: Reading from a MySQL table via ADO, I'm getting exception that occurs when reading one of the records: "Multiple-step operation generated errors".

SOLUTION: It's rare that Stack Overflow fails me completely, but in this case it seems I'm the only one on the planet that has ever seen this error during a read.

Yeah... right...

For the poor schmoe that comes behind me wondering what is causing this and how to fix it, it's a lot easier than it seems. All the advice on Stack Overflow and elsewhere will tell you you're storing an invalid value, or you need to switch to using a server side cursor, or you need to do a deep dive into the ADO connection properties. Since you're doing a select, not an insert or update, you figure it must be the ADO connection properties.

And it very well may be, but in my case it was a datetime value in the database that had been stored using ODBC MySQL drivers, and the read was done using ADO MySQL providers. Apparently, there's a difference. The value that the ODBC driver happily stored exceeds the ADO specification for datetimes, and when I pulled the TField.Value, the act of retrieving the value via ADO's ResultSet ActiveX object generated this oddly worded and completely useless exception message. It wasn't until I tried reading that single field from all the other rows in the database that I realized that it was only bad in in that one field, in that one row. Running a query via the mysql command line showed the value was 0007-10-12.

The solution therefore was to modify my application to detect that specific error based on the exception classname and message text and then, based on a configuration flag for that particular field and table, substitute the bad value with a null. The application is just supposed to push data from a legacy database up to a REST service at intervals. If a field is bad, there's no user present to correct it, so I just null it out and keep going.


Todd Grigsby