1.11M Members

Update database from DataGridView

 
0
 

Hi,

I'm using C#, Access 2007 and VS2008 to write a windows app.

I have populated a datagridview from a query (taking data from 2 tables). When the user clicks "Save", I want to be able to save any changes made in the datagridview to the database. Only one column in the datagridview is editable, so any changes will be made to just the one table in the database.

I could possibly do something using the CellEndEdit event, but that would fire for each cell that is updated, which is a bit clunky.

So, can anyone please tell me how I can write data back to the database, when the original datagridview is populated from a query?

Thanks in advance,
Jon

Question Answered as of 4 Years Ago by DdoubleD
 
-2
 

Hi,

I'm using C#, Access 2007 and VS2008 to write a windows app.

I have populated a datagridview from a query (taking data from 2 tables). When the user clicks "Save", I want to be able to save any changes made in the datagridview to the database. Only one column in the datagridview is editable, so any changes will be made to just the one table in the database.

I could possibly do something using the CellEndEdit event, but that would fire for each cell that is updated, which is a bit clunky.

So, can anyone please tell me how I can write data back to the database, when the original datagridview is populated from a query?

Thanks in advance,
Jon

Hello Jon,

For datagridview, you MUST have one Primary key in your database.

Try it out and let me know if you have any problem.

Also Please see: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/666835a2-50ec-415f-ba30-bb80ca51c91b

 
1
 

Welcome @i_microsoft.

We appreciate your knowledge. Please do not resurrect old/solved thread.

Thread Closed.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article