DataAbstract "not a legal oleaut date" exception


(afree) #1

When I look up data from a database, this “not a legal oleaut date” exception occurs.
WriteDataReader or WriteDataTable in Bin2DataStreamer.
Is there a way to avoid this exception without fixing data?
DataAbstract , c# Winform.

(antonk) #2


Unfortunately there is no way to avoid this exception w/o fixing the data (* see below). The issue is that the streamer needs to convert the DateTime value to a double to write it to the stream. If the incoming DateTime value doesn’t fit to the range that could be converted to a Double then it fails.

*There are 2 ways to fix the data:

  1. Fix the underlying data table data (this is not always possible)
  2. Wrap the data table on the Schema level:
    2.1. Open the server’s .daSchema file
    2.2. Go to the table containing bad data
    2.3. Open its Statements node
    2.4. Change its Statement type from AutoSQL to SQL and allow Schema Modeler to generate the SQL statement for you
    2.5. Amend the SQL statement to return fixed datetime value

Hope that helps

(afree) #3

Thank you for your answer.
If possible, I’d like the user to see it if they typed it incorrectly.
And when JsonDataStreamer or System.Runtime.Serialization.Formatters.Binary.BinaryFormatter was used, exception did not occur.
If I use this method, I would like to know which part of it is different from Bin2DataStreamer.
Thank you.

(antonk) #4

Quite expected as these 2 serializers use different ways of storing a System.DateTime value.

Bin2 serializer cannot handle DateTime values that are outside of the supported range (from 01/01/0100 up to 01/01/10000)