I am currently working on a project that involves the use of data base sources, namely ODBC. The problem is I have designed a form using the Data Source Configuration Wizard that doesn't update. I've ensured that I have a primary key in my data and that the Copy to output is set to "Copy Always". The code generated by the wizard, is as follows:
Public Class Form1
Private Sub GDBBindingNavigatorSaveItem_Click_
(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles GDBBindingNavigatorSaveItem.Click
Me.Validate()
Me.CAIBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.DataSet1)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DataSet1.CAI' table. You can move, or remove it, as needed.
Me.CAITableAdapter.Fill(Me.DataSet1.CAI)
End Sub
End Class
When this code is run the program executes in the expected manner until 'Me.TableAdapterManager.UpdateAll(Me.DataSet1)' at which point it warns of an 'InvalidOperationException was unhandled', more specifically that 'Update requires a valid UpdateCommand when passed DataRow collection with modified rows.' (This was the code the program inserted automatically and it doesn't run :'( ). I have attempted to fix the error by placing
DataSet1.AcceptChanges()
directly above 'Me.TableAdapterManager.UpdateAll(Me.DataSet1)', which gets rid of the exception but still does not update the database. Any help would be greatly appreciated. Thanks in advance