DateTime Null value in Typed DataSet gives Invalid Cast Exception - Please help !!!

  • Thread starter Thread starter Fresh_Air_Rider
  • Start date Start date
F

Fresh_Air_Rider

Hi Folks

I have a strongly typed dataset which works perfectly well until a NULL
value is returned for a DateTime field.

Whatever I try to do to test for a NULL value results in an Invalid
Cast Exception

I have tried Microsoft's suggestion of editing the XSD file as
follows:-

xmlns:codegen="urn:schemas-microsoft-com:xml-msprop"

nillable="true" msprop:nullValue="1980-01-01T00:00:00"

All of the following tests have resulted in an Invalid Cast Exception

_dsH.Headlines[0].DatePublished ==
System.DateTime.Parse("1980-01-01T00:00:00");

_dsH.Headlines[0].DatePublished == System.DBNull.Value;

_dsH.Headlines[0].DatePublished == SqlDateTime.Null.Value;

Could someone please give me a code snippet which tests a Typed DataSet
column of DateTime to see if it has a NULL value ?

Many thanks in advance

David Parry
 
Could someone please give me a code snippet which tests a Typed DataSet
column of DateTime to see if it has a NULL value ?

There should be a method called IsDatePublishedNull autogenerated for
you.
 
Jon

Yes, you're right, there certainly is a method called
IsDatePublishedNull.

Many thanks for pointing that out.

Regards
David
 
Back
Top