Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with DateTime and NULL columns in ADO.NET
Message
 
To
17/05/2005 20:38:09
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 1.1
Database:
MS SQL Server
Miscellaneous
Thread ID:
01015071
Message ID:
01015159
Views:
17
I think the value is actually stored as null, but if you do an explicit conversion from SqlDateTime to DateTime, the value gets converted to "1/1/1900 00:00:00". I tried this, and that is what appears to be happening:

DateTime dateTime;
SqlDateTime sqlDateTime;

sqlDateTime = SqlDateTime.Null;

dateTime = (DateTime)sqlDateTime;

I was unable to do an implicit conversion, but maybe that is what is going on with your and Kevin's code. Are you using C# or VB?

>You *do* realize that System.Data.SqlTypes.SqlDateTime.Null is actually "1/1/1900 00:00:00", right?
>
>~~Bonnie
>
>
>
>>I had to Google it to find the answer, and after looking at it, I think I am going to leave it the way it was. Serves me right for trying to be consistent.
>>
>>I do appreciate you and Kevin looking at it. Sometimes (ok, most of the time) .NET makes me feel stupid.
>>
>>>Good going, Chris!! I guess my head wasn't screwed on correctly this afternoon ... dunno how I missed this! You may give Kevin and I 50 lashes!! <g>
>>>
>>>~~Bonnie
Chris McCandless
Red Sky Software
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform