Hi
When I try to update using the code below I get this error "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records."
Imports System.Data
Imports System.Data.OleDb
Private Shared MyDataAdapter As OleDbDataAdapter
Private Shared MyDataSet As DataSet
Sub BindGrid()
Dim sqlStr As String = "SELECT * FROM tbl_Work"
Dim conn As OleDbConnection = New OleDbConnection(MyProviderString)
MyDataAdapter = New OleDbDataAdapter(sqlStr, conn)
MyDataSet = New DataSet
MyDataAdapter.Fill(MyDataSet, "tbl_Work")
Dim MyDataView As DataView = MyDataSet.Tables("tbl_Work").DefaultView
DataGridView1.DataSource = MyDataSet.Tables("tbl_Work").DefaultView
End Sub
Private Sub TabControl1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabControl1.MouseClick
BindGrid()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim myBuilder As OleDbCommandBuilder = New OleDbCommandBuilder(MyDataAdapter)
myBuilder.GetUpdateCommand()
MyDataAdapter.UpdateCommand = myBuilder.GetUpdateCommand()
MyDataAdapter.Update(MyDataSet, "tbl_Work")
MyDataSet.AcceptChanges()
MsgBox("Updation is over")
End Sub
Am I missing something here?
Best Regards