Database updates in LINQ

  • Thread starter Thread starter julio
  • Start date Start date
J

julio

I am trying to use Update to save changes made on two DataGridView's to two
tables (Posts & PostDetails) with a FK relationship. I say

private void bUpdate_Click(object sender, EventArgs e) {
try {

CustomerDataSetTableAdapters.TableAdapterManager taManager = new
CustomerDataSetTableAdapters.TableAdapterManager();
taManager.PostsTableAdapter = postsTableAdapter;
taManager.PostDetailsTableAdapter = postDetailsTableAdapter;
postsBindingSource.EndEdit();
postsDetailsBindingSource.EndEdit();
taManager.UpdateAll(customerDataSet);
}
catch (System.Exception ex) {
MessageBox.Show(ex.Message.ToString());
}

}

It doesn't work. Note:
1. Changes (just DataGridView edits to existing records) don;t show in the
databse.
2. It doen't raise an exception.
3. CustomerDataSet (in UpdateAll() line) contains the new values.

Can you help?

Thanks
 
You realize what you have here is not LINQ, right?

As for the problem, try firing AcceptChanges on the DataSet prior to firing
off UpdateAll on the TableAdapter.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top