Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with DateTime and NULL columns in ADO.NET
Message
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:
01015078
Vues:
19
I would like to keep the value of the exitDateTime variable as null, but I can't seem to find the syntax:


else
exitDateTime = DBNull.Value;


Does not work.

>Hey, Chris,
>
>You need to check for null values first.
>
>
>DateTime exitDateTime;
>
>if(Convert.IsDBNull(Dr[drvPortfolio["EnterPriceDateTime"])==false)
>   exitDateTime = (DateTime)drvPortfolio["EnterPriceDateTime"];
>else
>   // whatever you want to do if IsDbNull returns a true
>
>
>There are variations on that syntax, that's the one I've often used
>
>HTH,
>Kevin
Chris McCandless
Red Sky Software
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform