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
ramesh rammi
NA
86
14k
row delete can't be effect on database
Mar 31 2018 5:07 AM
My code worked properly but row can't be delete from database table.in datatable row deleted.after call the .da.update(ds,"student") need to effected database table but row can't be deleted in database table
my code:
SqlConnection con =
new
SqlConnection(
"Data Source=AMMA-PC\\SQLEXPRESS;Initial Catalog=E_learn;Integrated Security=True"
);
string
query=
"select * from Student where sid="
+TextBox1.Text;
SqlDataAdapter da =
new
SqlDataAdapter(query, con);
SqlCommandBuilder br =
new
SqlCommandBuilder(da);
DataSet ds =
new
DataSet();
da.Fill(ds,
"Student"
);
if
(ds.Tables[0].Rows.Count > 0)
{
DataTable dt = ds.Tables[0];
DataColumn[] keyColumns =
new
DataColumn[1];
keyColumns[0] = dt.Columns[
"sid"
];
dt.PrimaryKey = keyColumns;
DataRow dr = dt.Rows[0];
dt.Rows.Remove(dr);
da.Update(ds,
"Student"
);
Response.Write(
"deleted successfully"
);
}
I think u have doubt about delete row. how should know row deleted from datatable in dataset. i had verfied through breaking points keys like F10,F11.at the time in dataset visualizer shows before call da.update(ds,"Student") i have row. after call da.update(ds,"Student").dataset visualizer shows row deleted but database does not effected.row can't be deleted from database . what is the problem
i don't know. please help me.
Thank u
Reply
Answers (
4
)
How Can i Download and install MVC for VS 2015?
Need clarification on xmldocument,xmlelement,xelement,xmlnod