March 5, 2005 at 1:09 am
Hi evryone
i am developing s/w using VB. Wheh i try ot delete records it doesnt delete.
if i insert new records then it is deleted. but already existed records doesnt delete. it gives error as below.
"Delete statement conflicted with column reference constraint "FK_voucher_header_customers" the conflict occurred in database bayan,table voucher_header,column cust_no"
what is solution of this error?
Pls reply soon its urgent
Waiting for reply.
thanx in advance
March 5, 2005 at 1:26 am
"Delete statement conflicted with column reference constraint "FK_voucher_header_customers" the conflict occurred in database bayan,table voucher_header,column cust_no"
YOu have a foreign key constraint on that table from where you are going to delete. Thts the reason it is not deleting.
Read FOREIGN KEY constraint from BOL for more information on Foreign keys.
If you still want to delete the records, you will have to drop the constraint.
DROP { [CONSTRAINT] constraint_name | COLUMN column_name }
--Kishore
March 5, 2005 at 1:30 am
Your database design has a foreign key between the table voucher_header and another table, likely named customers. Voucher_header a child table and has a cust_no that references the Customer table.
The database prevents any deletion of a customer that has an associated voucher_header.
How to proceed?
1) If you want to delete a customer, can you also delete any associated voucher_headers? If so, then do something like
DELETE voucher_header where cust_no = @Cust_No
DELETE customer where cust_no = @Cust_no.
You may have other child tables that you need to clear out too.
2) If you can't delete voucher_headers, my suggestion would be to maintain referential integrity and NOT delete customers. Perhaps you can inactivate them or somehow other indicate they are not to be used.
Scott Thornburg
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply