Saving DataSet changes on a DataGrid

  I have a button that saves changes to a DataSet. The data saves if I click the button, but if I use the alt shortcut, the changes don't make it to the database and the "HasChanges" property stays true.
The button click event fires  whether I click the button or use the alt shortcut.


 Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        Try

            myDataSet.Tables("g_sra").Rows(dgSRA.CurrentRowIndex).EndEdit()
            MyDataAdaptr1.Update(myDataSet, "g_sra")

            myDataSet("g_sra_assc").Rows(dgSRA.CurrentRowIndex).EndEdit()
            myDataAdaptr2.Update(myDataSet, "g_sra_assc")

            myFrmMsg = New frmMsg("Save Successful!")
            myFrmMsg.Show()

        Catch sce As SqlClient.SqlException
            MsgBox("Please fix errors.")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
seincAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mikal613Commented:
when you stepthrough the code what happens?
0
seincAuthor Commented:
Every line executes whether I click the button or use the alt shortcut.
If I use the alt shortcut, the little pencil icon in the datagrid row does not go away. It does go away if I click the button.
0
UnifiedISCommented:
You answered your own question!  The changes have not been committed if the pencil icon is still there.
do a dataset.acceptchanges before the update

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
seincAuthor Commented:
I am wondering why the change does not commit when the exact same code executes whether I click the button or type alt-U. I am calling endedit in case the user does not move to a different row.
If I call AcceptChanges, no updates will make it to the database since it makes added and modified rows "Unchanged" - the dataadapter will only update modified, added, and deleted rows.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.