The DeleteCommand
for my SqlDataSource
is giving me some issues because of primary/foreign keys I believe.
Here is the DeleteCommand:
DeleteCommand="delete from jm_AccountWorkFlowSteps where id = @stepID;delete from jm_AccountWorkFlowProcedure where id = @workFlowProcedureID;DELETE FROM [JM_AccountWorkFlowDetail] WHERE [workID] = @workID"
Now when I run this code in SQL it works just fine, the procedures table is deleted first which allows the WorkFlowDetail row to be deleted. But when I plug in the same SQL into the DeleteCommand it gives me the following error:
The DELETE statement conflicted with the REFERENCE constraint "FK_jm_AccountWorkFlowProcedure_jm_AccountWorkFlowProcedure". The conflict occurred in database "Collect2000", table "dbo.jm_AccountWorkFlowProcedure", column 'workID'.
The statement has been terminated.
Why would this work as expected in SQL but not in the DeleteCommand? And how can I get it to work?
The Procedure table has a foreign key to the WorkFlowTable so I am trying to delete this row first so it allows me to delete the other table row after.