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
 
Back
Top