• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 420
  • Last Modified:

Check for datagridview data changes

Hi all,

I'm using VS2005 (VB.NET) winforms.

I have the following code to update my SQL Server database with datagridview changes:

I would like to check if there have been any changes to the data before I execute this line as it fails if there have not been any changes.

1 Solution
well firstly, if you bind a dataset to a datagridview then the dataset will be updated automatically. you can see if the dataset has changes (theDataSet.HasChanges()) or you can get changes:

Dim theChanges as new DataSet() = theDataSet.GetChanges()


this will return you the changes that the user has made in the first datatable I believe.

does this help you?

you could also implement a CellBeginEdit event for the datagridview. This will fire when the user starts to edit that cell but I don't think it will fire when the user actually starts to change the cell contents but will fire when it gains "input" status (ready to edit the content)

you can use the CellValueChanged in the datagridview, the event, which will fire when the cell value has been changed.

FMabeyAuthor Commented:
That is spot on!

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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