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

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
 
F

Fresh_Air_Rider

Hi Jon

Many thanks for replying to my post which I will now go and read within
the microsoft.public.dotnet.genera­l forum.

Apologies for the cross post but with some many candidate forums it's
difficult to know which one to target for a response.

Anyway, thanks once again for your reply.

David
 
C

Chad Z. Hower aka Kudzu

(e-mail address removed) wrote in @g43g2000cwa.googlegroups.com:
Apologies for the cross post but with some many candidate forums it's
difficult to know which one to target for a response.

Best to try the most suitable first, and if no response then possibly try another.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
 
J

Jon Skeet [C# MVP]

Many thanks for replying to my post which I will now go and read within
the microsoft.public.dotnet.genera­l forum.

Apologies for the cross post but with some many candidate forums it's
difficult to know which one to target for a response.

In that case it's best to try one which you think is best, and then
wait. If you really feel it's suitable to post to multiple groups, it's
better to cross-post (one article which reaches several groups) rather
than multi-post (several articles, one per group, even if they have the
same text).
 
C

Cool Guy

Apologies for the cross post but with some many candidate forums it's
difficult to know which one to target for a response.

General rule: if you're really not sure, crosspost (not multipost) to all
of them.

Crossposting is specifying multiple target newsgroups in the 'Newsgroups'
field. Multiposting is posting the same article to multiple newsgroups,
manually.

The problem with multiposting is that it can waste people's time -- someone
might not realise that you've already had a reply in another group you've
posted it to, and might then answer it in the current group. Also,
newsreaders can detect crossposted articles, and mark the duplicates as
/read/ appropriately.
 
C

Chad Z. Hower aka Kudzu

Jon Skeet said:
wait. If you really feel it's suitable to post to multiple groups, it's
better to cross-post (one article which reaches several groups) rather

A note on cross posting - and mind you this is just my opinion.

Cross posting is WAY over used on these groups and I wish that it were "politely policed" a bit more.
Worse yet, when people do cross post they dont just cross post to 1-2, or even 3 groups but half a
dozen ore more. :(

Cross posting is certainly better than "multi posting" but its still considered rude by many, especially
if its done carelessly. On many servers cross posting is against the guidelines, or even explicitly
disabled.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/
 
J

Jon Skeet [C# MVP]

Chad Z. Hower aka Kudzu said:
A note on cross posting - and mind you this is just my opinion.

Cross posting is WAY over used on these groups and I wish that it
were "politely policed" a bit more. Worse yet, when people do cross
post they dont just cross post to 1-2, or even 3 groups but half a
dozen ore more. :(

Cross posting is certainly better than "multi posting" but its still
considered rude by many, especially if its done carelessly. On many
servers cross posting is against the guidelines, or even explicitly
disabled.

Oh absolutely. Yes, I'm *much* more in favour of people only posting to
a single group. Indeed, I rarely reply to a message which is posted to
too many groups, as it perpetuates the problem.
 
C

Chad Z. Hower aka Kudzu

Jon Skeet said:
Oh absolutely. Yes, I'm *much* more in favour of people only posting
to a single group. Indeed, I rarely reply to a message which is posted
to too many groups, as it perpetuates the problem.

I've read your newsgoup posting guidelines. Its similar to the one used on the Borland groups. Id like to
suggest some updates to it however - are you interested? Should we talk by e-mail?

Or would you mind if I copied it as a template (With credit of course) and hosted an edited copy?


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
 
J

Jon Skeet [C# MVP]

Chad Z. Hower aka Kudzu said:
I've read your newsgoup posting guidelines. Its similar to the one
used on the Borland groups. Id like to suggest some updates to it
however - are you interested? Should we talk by e-mail?

Sounds good - I'll look foward to hearing from you.
Or would you mind if I copied it as a template (With credit of
course) and hosted an edited copy?

That's absolutely fine.
 
N

No One

Hi Folks

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

The datatime objects in .Net are non-nullable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top