PC Review


Reply
Thread Tools Rate Thread

How to set EnforceConstraints on a datatable?

 
 
W.G. Rowland
Guest
Posts: n/a
 
      11th Sep 2004
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


 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      11th Sep 2004
Hi,

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

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"W.G. Rowland" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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
>



 
Reply With Quote
 
W.G. Rowland
Guest
Posts: n/a
 
      11th Sep 2004
Thanks, that was exactly what I was looking for.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling EnforceConstraints John Microsoft ADO .NET 1 28th Feb 2008 10:36 PM
DataTable RowChanging event occurs in Fill with EnforceConstraints =?Utf-8?B?RGFuaWVsIEdyYXNzaWNr?= Microsoft Dot NET Framework Forms 4 11th Dec 2006 01:06 PM
userDs1.EnforceConstraints problem Britney Microsoft ASP .NET 0 15th Sep 2005 04:03 PM
Does enforceconstraints mean errors or relations?? bjako Microsoft ADO .NET 1 3rd Mar 2005 01:36 AM
Applying DeleteRule even though EnforceConstraints is false? Ed Microsoft ADO .NET 3 14th Jan 2004 04:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:02 PM.