Problem With Typed DataSet Schema

O

OhioGolfer

My app consists of a windows form client, a business logic layer, and a
web application that hosts a strongly typed dataset and a variety of
web services. The web services retrieve the data from the SQL Server
database, do whatever logical processing is required, and return the
results to the business logic layer, which holds the data in an
instance of the typed dataset.

In my typed dataset, I have added annotations to the xsd file to
provide nullValue values, and avoid the StrongTypingException issue
when nulls are present in the data store. However, when the app runs,
the StrongTypingException still is thrown. When I go into the
Reference.vb file, and check the xsd that the reference is hitting, the
annotations are not there. It is obviously generating its own schema,
while I want it to use the schema in the web application.

Any ideas on how to get around this? It is driving me crazy . . .

Jeff
 
K

Kevin Yu [MSFT]

Hi Jeff,

I would like to know how you set the nullValue for a certain column. Did
you modified the attribute in the xsd? Also are the business logic layer
and the webservice layer referencing to the same typed DataSet class?

Please take a look at the following KB article. It will be a good guide for
your to handle DBNull values in typed DataSet.

http://support.microsoft.com/default.aspx?scid=kb;en-us;318048

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
O

OhioGolfer

Kevin -- I modified the .xsd file by adding the
xmlns:codegen="urn:schemas-microsoft-com:xml-msprop" reference, and
adding codegen:nullValue="_empty" or "0" or "1980-01-01", depending
upon the field type involved. This works fine on the server side --
the .vb file for the typed dataset properly incorporates the
annotations, and no StrongTypingException is thrown.

The problem arises on the client side. The web reference to the web
service regenerates the schema as part of the reference, and drops the
annotations. Thus, the Reference.vb file throws the
StrongTypingException. I have tried modifying the .wsdl file to point
to the "original" xsd schema, but that doesn't work. I could modify
the Reference.vb file, but this is an unstable solution, as those
changes will be lost anytime the reference is updated.

There have been a few allusions to this as a known bug in the web
service treatment of typed datasets in other forums, but I have yet to
see a proposed solution. Hope you can shed some light on this.

Jeff
 
K

Kevin Yu [MSFT]

Hi Jeff,

With my further research, I found that it is a known issue in ADO .net.
When XmlSerializing the typed dataset, the extended properties will not be
persisted. So the nullValue attribute cannot be passed through a web
service.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
O

OhioGolfer

Kevin -- That's it? No workaround, no indication as to whether this is
fixed in 2.0? With the push of Smart Client architecture, I find it
hard to believe that MS is simply stating this can't be done. Are you
really implying that we either have to abandon typed datasets when
using web services or make all of our database fields not nullable, and
provide default values?

Very disappointing.

Jeff
 
O

OhioGolfer

Kevin (and any others who may encounter this issue):

After much agonizing and trial and error, I have found a workaround
that enables the client to capture the nullValue attributes.

Assuming a typed datset named myData, generate the dataset. In the
myData.vb file, modify the Init_Class procedure for each datatable in
your dataset by including the following for any nullable fields. (Here
I am assuming fields called myString, myInt, myDate):
columnmyString.ExtendedProperties.Add("nullValue","_empty")
columnmyInt.ExtendedProperties.Add("nullValue","0")
columnmyDate.ExtendedProperties.Add("nullValue,"2000-01-01")

Save the myData.vb file. Delete any existing web references that call
for the myData schema, and create a new web reference. If you check
the myData.xsd file generated, as well as the Reference.vb file, you
will see that the attributes are preserved, and the calls to the
StrongTypingException in the Reference.vb file no longer exist.

One caveat here is that this should be done after you have finalized
the structure of your typed dataset. Regenerating the .xsd file on the
server will regenerate the .vb file on the server, and you will have to
add the ExtendedProperties again.

Hope this helps others. Is Microsoft fixing this in 2.0?

Jeff
 
K

Kevin Yu [MSFT]

Hi Jeff,

Thanks for your workaround. So far, I didn't see .NET 2.0 framework has
fixed this yet.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top