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:
01015077
Vues:
23
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform