DataSet.ReadXML is ignoring UniqueConstraint on table... (ADO.NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a DataTable with a UniqueConstraint defined for columns A and B:

ds.tables("myTab").constraints("myUC") has columns A and B in its Columns
collection

But ReadXML will load an XML document that has duplicate values for columns
A and B. After invoking ReadXML, the table contains:

ds.tables("myTab").rows(0)("A") value of 0 (integer)
ds.tables("myTab").rows(0)("B") value of "1" (string)

ds.tables("myTab").rows(1)("A") value of 0 (integer)
ds.tables("myTab").rows(1)("B") value of "1" (string)

I've tried both ReadSchema and IgnoreSchema values for XmlReadMode...both
allow the duplicate rows to be loaded.

Shouldn't ReadXML abide by the defined constraints?????

DT
 
Oooops!!!

DataSet.EnforceConstraints wasn't set to "True"

Don't know when/how it got set to False, since the default is True.
Explicitly setting it to True fixed the problem...

DT
 

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

Back
Top