I try to update a table of my database in MySQL from a DataGridView in my VB.NET project but I get the following error:
concurrency violation the updatecommand affected 0 of the expected 1 records.
The code I have is the following:
Private Sub btnUpdateServices_Click(sender As Object, e As EventArgs) Handles btnUpdateServices.Click
If cbxEmployee.Text = "" Then
MsgBox("You must select a person in charge of health care giver.")
Else
InsertarHCG()
Dim MyBuilder As MySql.Data.MySqlClient.MySqlCommandBuilder
MyBuilder = New MySql.Data.MySqlClient.MySqlCommandBuilder(connect.cur_da)
dgvServicePlan.EndEdit()
Try
connect.cur_da.Update(dt)
clsLogger.logEvent("Changes in the service plan successful.")
MessageBox.Show("Service plan successfully updated.")
Catch ex As Exception
MessageBox.Show("Could not update the service plan.")
End Try
Me.Close()
End If