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:
01015078
Views:
18
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform