Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

Connected Datagrid

I would like to make a vb.net datagrid that is always connected to an sqlserver table, kinda like make a change to an access database.  When a change is made, the datagrid and backend database is always updated.  Can someone lead me in the right direction (ie. what event should my updates be triggered from, what is the exact syntax for setting up the update commands, etc.).  I don't want to have to click on a button to post my changes.

I have only used a datagrid to display data, and therefore it has always been disconnected from the database.  I'm not sure what I need to do to have it connected.

Thanks
0
Fraser_Admin
Asked:
Fraser_Admin
1 Solution
 
Fraser_AdminAuthor Commented:
Thank you.
0
 
amyhxuCommented:
You can update database in the DataGrid's CurrentCellChanged event. If you are using SqlDataAdapter to populate the DataSet that is the datasource of the DataGrid, and your data are only from one table, then simply use something like:
mySqlDataAdapter.Update(myDataSet)
The DataAdapter is smart enough to automatically open and close the connection.

But I don't think this is a good idea to update your database, since it will update so frequently and cause bad performance. I would suggest to update the database when the datagrid is closing or refreshing, depending on your program. If you could post your program, we can provide better suggestions based on your program.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now