DBNull problems - typed datasets - webservices

J

JezB

I'm using a typed dataset to get rows from a database, but getting an
invalid cast exception when trying to examine columns in that row which are
null in the database. This is because of some code generated within the
typed dataset's class (eg. myDataSet.cs) :-

catch (InvalidCastException e) {
throw new StrongTypingException("Cannot get value because it is
DBNull.", e);
}

I know I can force a change of this code by setting a NullValue property of
the specific elements within my dataset. However, when I expose the dataset
schema through a web service (it's exposed by having an exposed method
return a dataset of this type), this change seems to be ignored. It seems to
regenerate the default code in a class file called Reference.cs - and I must
admit I'm not quite sure what's going on here.

Could anyone explain this ? and what can I do to resolve this issue ?
 
M

Miha Markic

Hi JezB,

For every property (field) that can be null there is a Is*fieldname*Null()
method in typed dataset.
 
J

JezB

You're right !! How did I miss this ?
Thanks.

However, I'd still like to know why exposing a dataset as a webservice
changes the generated code.
 
K

Kathleen Dollard

Jeff,

A coupde of weeks back there was a thread on using nulls in webservices. I
haven't actually done this, but there are apparenly some problems. You may
want to review. "codegen:nullValue Still not working for me" to see if its
relevant to your situation.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top