Check for datagridview data changes

Posted on 2007-08-10
Last Modified: 2010-05-18
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.

Question by:FMabey
    LVL 53

    Accepted 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.

    LVL 3

    Author Comment

    That is spot on!

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    731 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now