EndEdit not working

I have made a VB application (Beta 2) and have put in a DataGridView linked to an Access database.  The DataGridView displays the database perfectly.

However I would like to add data to the database.  I put a button on the form with the following code. Something very simple to start.

In the DataGridView form it updates perfectly however it does not save the data to the actual Access database.

In the old versions of VB I could use the .update command and it would work.  Now .update is invalid.

What am I doing wrong

------------------------------------------
Here is my code for the button


Dim
drv As Data.DataRowView = Data1.AddNew
drv.BeginEdit()
drv(
"BusinessType") = "ABCDE"
drv.EndEdit()



Answer this question

EndEdit not working

  • John Landreth

    Hi Scott,

    As you have discovered, EndEdit() does not cause the DataGridView to stop edit mode. Instead, you should call Validate on the container. So if the DataGridView is placed directly on your form then the following code should work:


    Dim drv As Data.DataRowView = Data1.AddNew
    drv.BeginEdit()
    drv(
    "BusinessType") = "ABCDE"
    Me.Validate()
    drv.EndEdit()

     

    I hope this helps.

    Jay Hickerson
    Visual Basic Team


  • EndEdit not working