четверг, 21 октября 2010 г.

.NET 2.0: Query to MS Access database throws "The provider could not determine the Object value" exception.

Recently I faced with the weird issue. My .NET 2.0 application tried to perform very simple query to table located in MS Access 2007 database, but call of ICriteria.List() method was throwing exception "could not execute query {QUERY_TEXT}". Inner exception looked like this: "The provider could not determine the Object value. For example, the row was just created, the default for the Object column was not available, and the consumer had not yet set a new Object value.". I want to pay your attention on the fact that given table contained field of Memo data type.
I spent I lot of time on investigation of this issue and finally found cause of the problem. The fact is one of values in Memo field was corrupted somehow. Exception was eliminated after Access utility Compact and Repair Database/Project launching (you can find it on the Tools menu) on my database.
Hopefully, this post will save some time for somebody :)
P.S. Value of corrupted field, of course, wasn't restored and was replaced with line of '#' characters. Some time later I faced with it when my application threw new exception during attempt of deserialization of binary value stored there.