Tech
Forums
Jobs
Books
Events
Live
Learn
More
Training
Interviews
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
6
Reply
How to delete from more than one table
Joma Rajab
Aug 16 2016 8:12 PM
298
Reply
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
6
)
Next Recommended Forum
Hoe to make a selected column distinct in inner join
View and Tables