By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,903 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,903 IT Pros & Developers. It's quick & easy.

Dataset diffgram doesn't set xsi:nil for nullable elements

P: n/a
I found a post about this exact issue:

http://groups.google.com/group/micro...073666a4035bd5

but it only shows how to correct the issue manually, not whether it is
a known bug.

My situation is slightly different only in that the xml data and schema
I have are coming directly from the DataSet using:
DataSet.GetXml()
DataSet.GetXmlSchema()

I have a nullable numeric database column: MONTHS
I want to be able to actualy set the value to null in the database.

Here is what I actually get from the DataSet methods above when MONTHS
is null:
DATA: <MONTHS></MONTHS>
SCHEMA: <xs:element name="MONTHS" type="xs:decimal" minOccurs="0" />

If I try to load up a DataSet using DataSet.ReadXml() I get an error as
it tries to parse the decimal value (with enforceconstraints = false).
It doesn't recognize its a nullable element. (see link at the beginning
of this post)

What is apparently required to actually do the load and have the schema
not bark at the data:
DATA: <MONTHS xsi:nil="true"></MONTHS>
SCHEMA: <xs:element name="MONTHS" type="xs:decimal" minOccurs="0"
nillable="true" />

So my question is:
Why do the DataSet methods not apply the "xsi:nil" and "nillable"
attributes for a known nullable element?
Is this a failure of the DataAdpater (I'm using OleDb)?
It does set minOccurs="0" so it knows it is nullable right!

I had to MANUALLY set these attributes on the DATA and SCHEMA as well
as set the "xsi" namespace on the diffgram node to get this to work,
which is NOT acceptable.
If I do a GetXML() and GetSchema() on a DataSet and simply try to load
a data set with that exact information it should not fail.

Known Bug?
Have I missed something obivous?
Any insight would be appreciated as I don't want to have to set these
attributes manually!

Mar 15 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Sorry I should clarify.
I get this from the DataSet
DATA: <MONTHS>0</MONTHS>
and before I load it back to the DataSet I change it to this:
DATA: <MONTHS></MONTHS>

Mar 15 '06 #2

P: n/a
I did some more checking and it looks like the W3C defines this pretty
well:

http://www.w3.org/2002/ws/databindin...c.html#issue-7

So it seems the DataSet.GetXml method just doesn't bother to put the
xsi:nil on the nullable columns.

I would like to have seen this as an option on GetXml, so you'd at
least be able to tell GetXml whether you want the nil attribute or not.
For now I will continue to set them manually.

Mar 20 '06 #3

P: n/a
I did some more poking around and it seems the W3C defines this pretty
well.
http://www.w3.org/2002/ws/databindin...c.html#issue-7
so it looks like the DataSet just doesn't bother to spit out the
xsi:nil on a nullable column.

I would like to have seen an option for DataSet.GetXml that simply
allows you to set whether it outputs nulls or not.

Mar 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.