Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Failed to enable constraints when filling dataTables

Status
Not open for further replies.

robert201

Programmer
Jul 18, 2007
80
0
0
TH
Hello,

VS 2005 using Typed Datasets.

I have this problem that I am trying to fill 2 data tables 'Orders' (parent table) and 'OrderDetails' (child table).

In the dataset designer I have added the relationship between them.

Code:
 Me.DsAddComponetAndEquipment1.EnforceConstraints = False
            Me.TA_Orders_dsCodered1.ClearBeforeFill = False
            Me.TA_Orders_dsCodered1.Fill(Me.DsAddComponetAndEquipment1.Orders)
            Me.TA_OrderDetails_dsCodeRed1.Fill(Me.DsAddComponetAndEquipment1.OrderDetails)
           Me.DsAddComponetAndEquipment1.EnforceConstraints = True

I what I have tried a different combination of the above. I know that by default the data table is cleared, so if there are values in the child table, then it might throw this error. So setting it to false didn't work.

When i enforce constraints to false, but as soon as I set it to true after the data tables are filled, it will throw the error.

Error Message:
"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints"

Many thanks for any assistance,

R
 
You might try spinning through your new child rows looking for missing parent records. Then you could fix them before turning your constraints back on. Good Luck!
 
Hello,

The data is clean there is nothing wrong with missing foreign keys.

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top