I need to delete from multiple tables which are linked to each other and the delete is based on a selected value from a drop-down list and this drop-down list contains id of the first table
the query below works fine for deleting from Material table where there is no row for that material id in other tables. However, when id is in other tables I could not delete
- SqlCommand cmd = new SqlCommand("Delete From dbo.Material Where MaId='" + DropDownList5.SelectedItem.Value.ToString() + "'; Delete from Quiz where MaID = '" + DropDownList5.DataValueField + "';Delete from Lastviewed where MaID = '" + DropDownList5.DataValueField + "'; Delete from Comments where MaID = '" + DropDownList5.DataValueField + "'; ", conn);
Thank you
Pratik ShirsePosted Sep 10, 2016, 6:48 AM
Midhun TpPosted Aug 17, 2016, 10:46 AM
Bikesh SrivastavaPosted Aug 17, 2016, 9:19 AM
Tapan PatelPosted Aug 17, 2016, 8:53 AM
Joma RajabPosted Aug 17, 2016, 5:16 AM
Tapan PatelPosted Aug 16, 2016, 9:26 PM
http://stackoverflow.com/questions/6260688/how-do-i-use-cascade-delete-with-sql-server