Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with DateTime and NULL columns in ADO.NET
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 1.1
Database:
MS SQL Server
Miscellaneous
Thread ID:
01015071
Message ID:
01015077
Views:
22
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform