The INSERT statement conflicted with the FOREIGN KEY constraint

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi
ive configured my tableAdapters CRUD commands with stored procedures. but when i want to insert relational data via TableAdapterManager.UpdateAll method,
i got the following exception :

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Orders_Customers". The conflict occurred in database "Test2", table "dbo.Customers", column CustomerID.
The statement has been terminated.


if i use int dataType as Pk in my tables (in sql server) i got this error :

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records

but when i use uniqueidentifier as PK in tables and tableAdapter CRUD commands configured with text, it works, but if tableAdapter commands configured with stored procedures,
i got the first error. why and how to fix that ?

Note : i think this maybe insert command for child table needs to PK of inserted parent record as FK, is this correct ? if yes, how to fix this problem ?
Thanks<hr class="sig this is my Signature

View the full article
 
Back
Top