Connected Datagrid

Posted on 2005-03-08
Medium Priority
Last Modified: 2010-04-23
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.

Question by:Fraser_Admin
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Author Comment

ID: 13487751
Thank you.
LVL 14

Accepted Solution

amyhxu earned 2000 total points
ID: 13491612
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:
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.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question