I have the following code that is supposed to check that a value in a data reader is not null. If it is then the method should return a null value or null DateTime for use later.
private static DateTime safeGetDateTime(OleDbDataReader dr, int idx)
{
if (!dr.IsDBNull(idx))
return dr.GetDateTime(idx);
else return DateTime.MinValue;
}
I have tried just returning null but as the methods return type is "DateTime", this did not work. I then tried to return DateTime.MinValue if a null is picked up by the datareader. This has given me the following error:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Any help is appreciated.