Since nullable has been baked into .NET, I had to see if that carried over to ADO.NET. Now I know that datasets' behavior with Nullable types was so broken that it was removed from the scope of .NET 2.0, but I wanted to go back and look at my previous tests with dbnull and Nullable types.
Nullable may be "fixed", but there is still no correlation between them. I know that the fix was for totally different reasons, but I just still had to see.
It is still necessary to test for a dbnull before trying to populate a Nullable<DateTime>, for example.
Any attempts to return date data that is nullable with a datareader.GetDateTime() will give a runtime error. DataReader knows this value is a dbnull, but you will just have to check for yourself and do the little bit of extra work.
nulld Nullable<DateTime>;
'get some data into a reader and read it
if (myReader.IsDBNull(mycolumn)){ nulld=null;else nulld=myReader.GetDateTime(mycolumn);}
Remember Me
See my speaking schedule for more events
User Group Leader
Hosted by:
Powered by: newtelligence dasBlog 2.0.7226.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Julie Lerman
E-mail