TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Joma Rajab
NA
110
51.9k
How to delete from more than one table
Aug 16 2016 8:12 PM
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
Reply
Answers (
6
)
Hoe to make a selected column distinct in inner join
View and Tables