Newbie question-DataAdapter Fill errors with any null data

  • Thread starter Thread starter PeteJ
  • Start date Start date
P

PeteJ

Greetings to all-
An ADO newbie question...

Has anyone else encountered this?
When employing DataAdapter.Fill to initially populate a table in a typed
dataset, if there is null data in any column the fill method throws an error
about a constraint violation.
There are no constraints defined. The columns allow nulls.

Thanks
 
Did you generate your typed DataSet from an XML Schema (via xsd.exe)? Did
your XML Schema disallow 'nulls' on the column? Maybe that would impose the
constraint...
 
Thanks for the response!
Yes, I generated the typed DataSet from an xml schema. I created the schema
interactively using the GUI tool to match the SQL tables. No constraints
were placed on the Sql tables regarding nulls except for the pk (autoinc).
To begin with I set no XML properties and had the Fill method fail.
Then I tried explicitly setting the "nillable" property, the default value
for which is "Default," to True for every XML column.
Again, if a row contains a null value in any column the Fill fails.

The error I am getting is:
"Failed to enable constraints. One or more rows contain values violating
non-null, unique, or foreign-key constraints."

I have no foreign-keys established (this is a test).
I only have non-null constraints on the primary key column.
The moment I add data to each column, the Fill executes without error.

???
 
Thanks, Corey
After further testing, the XML nillable property is the reason why the DA
Fill method fails. The Default value for the nillable property is false. It
seems, then, if you expect null values in any column you need to explicitly
set the XML nillable property to true.

-Pete
 
Interesting. Playing around, I came across this problem as well. My SQL,
though, is a UNION with the 2 SELECTS hitting the same table. When run, the
resulting data didn't have any nulls in it, and no non-unique rows/columns.

Pete, how do you set the nillable property? I haven't come across that one
before.

Thanks!
Corey.
 
Back
Top