Hello,
I'm using the following code to load data on a gridView and bind them to a bindNavigator.
da = new SqlDataAdapter("SELECT * FROM Users", connectionstring);
ds = new DataSet();
da.Fill(ds);
bs = new BindingSource();
bs.DataSource = ds.Tables[0].DefaultView;
userBindNav.BindingSource = bs;
userGridView.DataSource = bs;
How can I save changes to database after editing data (insert, update, delete)?
Thank you in advance.
Loading
DealyPosted May 13, 2015, 7:53 AM
This is what I've tried but I'm getting the following message "Update requires a valid UpdateCommand when passed datarow collection with modified rows."
private void saveToolStripButton_Click(object sender, EventArgs e)
{
try
{
da.Update(ds.Tables[0]);
}
catch (Exception ex){MessageBox.Show(ex.Message);}
}
Any suggestions?
Nanhe SiddiquePosted May 13, 2015, 2:32 AM
da.Update(ds.Tables(0))
it may help you
Dipankar BiswasPosted May 13, 2015, 2:24 AM
check this link..http://www.codeproject.com/Questions/482144/C-plushowplustoplussavepluschangesplusinplusdata
http://stackoverflow.com/questions/17807373/why-it-doesnt-save-changes-into-datatable-from-datagridview