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);
please help
Thank you