Hi i am using sql data source to delete first from Child Table and second check if there is no child go and delete the primary key in Parent table
this is my code
<asp:SqlDataSource ID="SDSOrdersGrid0" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
Set @OrderIDinWeek=(Select order_dtl_id from Weeks where IdWeek=@IDweek)
DELETE FROM Weeks WHERE (IDWeek = @IDWeek)
IF (SELECT count(*) FROM weeks WHERE order_dtl_id =@OrderIDinWeek) =0
delete from order_dtl where order_dtl_id= @OrderIDinWeek
View Complete Post