Click here to Skip to main content
16,015,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to update my database from a datagridview, but although the code compiles, the changes aren't saved.

Basically:
1)bind datagridview to a query,
2)make changes to the data on the datagridview,
3)use cellendedit to capture change and update database.

Please take a look at the code below.

Sorry for such a simple question, but I've been trawling the net and haven't found a solution using Linq that works.

What I have tried:

C#
private void grdBOOK_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            using (lnkTRADERDataContext DATActx = new lnkTRADERDataContext())
            {
                grdBOOK.EndEdit();
                DATActx.SubmitChanges();
            }
}
Posted
Updated 12-Apr-16 1:03am
v4

1 solution

 
Share this answer
 
Comments
Trader999 12-Apr-16 19:01pm    
Thanks this was driving me nuts. So I'm expecting too much from the binding and SubmitChanges command. Instead the code needs to find out which record was changed and change that value using a query.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900