How to set EnforceConstraints on a datatable?

W

W.G. Rowland

I have an empty database I need to do some bulk data filling on from a
collection of datatables.. Since there are various constraints that are
invalid until all the data is uploaded I need to turn off constraint
checking while the DataAdapter.Update command is running.

All this was fine until I decided there was no reason to be using datasets
when all they were doing were wrapping single datatables..

The problem.. I can't find any equivalent of .EnforceConstraints in the
datatable..

I wrap the code in a dataset, turn .EnforceConstraints=false, then send the
datatable (extracted out of the dataset because the database code expects a
datatable) and the update works fine..

I take the same datatable without wrapping it in a dataset and the update
crashes due to constraint issues..

The dataset is obviously performing some kind of operation on the datatable
when the flag is set... But how do I do the same thing to the datatable
directly? Is there a way?

Thanks in advance,
WGR
 
M

Miha Markic [MVP C#]

Hi,

I would try changing or removing DataTable.Constraints and then reapplying
them.
 

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

Top