Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
how to update datatable into sql table using c#
Durga Velusamy
8y
243
1
Reply
DataRow dr = dt.Rows.Find(new object[] { custm_id });
if (dr == null)
{
// dt.Rows.Add(dr);
dr = dt.NewRow();
val=true;
dr["custmid"] = custm_id;
}
else
{
dr.BeginEdit();
}
dr["fieldname"] = "test";
if (val)
{
dt.Rows.Add(dr);
}
else
{
dr.EndEdit();
}
like this i have edited table.
changes affected in datatable
SqlDataAdapter adapter;
using (adapter = new SqlDataAdapter("SELECT fieldname FROM customlist", con))
using (new SqlCommandBuilder(adapter))
{
adapter.Update(dt);
}
when i try to update
its updatating only new row. not updating edited rows into sql table.
how is possible any one help
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Write c# code that auto add stored procedure at run time
How to Convert .dbproj to .sqlproj programmatically using C#