468,256 Members | 1,426 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,256 developers. It's quick & easy.

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

I found a post about this exact issue:


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:

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:
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
3 2397
Sorry I should clarify.
I get this from the DataSet
and before I load it back to the DataSet I change it to this:

Mar 15 '06 #2
I did some more checking and it looks like the W3C defines this pretty


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
I did some more poking around and it seems the W3C defines this pretty
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.

Similar topics

reply views Thread by Stefan Prange | last post: by
2 posts views Thread by Wayne Wengert | last post: by
reply views Thread by John Jenkins | last post: by
1 post views Thread by =?Utf-8?B?TmFiZWVsIE1vZWVu?= | last post: by
2 posts views Thread by =?iso-8859-1?q?Norbert_P=FCrringer?= | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.