Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with DateTime and NULL columns in ADO.NET
Message
 
À
17/05/2005 20:38:09
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 1.1
Database:
MS SQL Server
Divers
Thread ID:
01015071
Message ID:
01015159
Vues:
18
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform