Public Class Form1 Dim dt As New DataTable Dim dt1 As New DataTable Dim connStr As String = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = test.ACCDB" Private sqlStr1 = "SELECT * FROM Customer" Private sqlStr2 = "SELECT * FROM Test"
Private Sub Load(...) Handles Button1.Click Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr1, connStr) dataAdapter.Fill(dt) DataGridView1.DataSource = dt End Sub
Private Sub Move(...) Handles Button2.Click dt1 = dt.Copy DataGridView2.DataSource = dt1 End Sub
Private Sub Update(...) Handles Button3.Click Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr2, connStr) Dim commandbuilder As New OleDb.OleDbCommandBuilder(dataAdapter) dataAdapter.Update(dt1) End Sub
End Class
|
All,
What I am trying to do is pull info from a table into my datagridview1 (which is fine). Then I want to move that info to datagridview2, then use the update method to move the information from dgv2 back to access into a DIFFERENT table.
The error when I delete a record from dgv2 and proceed to update: "Concurrency violation: the DeleteCommand affected 0 of the expected 1 records."
.
Any help is appreciated.
Thank you,
Ashley