Hi all,
This is my first attempt to update an access database in VB.Net 2005. It
goes broadly as follows (I have condensed it):
Dim MyConnection As New Data.OleDb.OleD bConnection
MyConnection.Co nnectionString = ("Provider=Micr osoft.Jet.OLEDB .4.0;
Data Source=c:\books .mdb")
Dim Myadaptor As OleDb.OleDbData Adapter
Myadaptor = New OleDb.OleDbData Adapter("select * from stockitems",
MyConnection)
Dim MyDataSet As New DataSet
MyConnection.Op en()
Myadaptor.Fill( MyDataSet)
Dim newRow As DataRow = MyDataSet.Table s(0).NewRow
newRow("code") = "New Code"
MyDataSet.Table s(0).Rows.Add(n ewRow)
Myadaptor.Updat e(MyDataSet)
MyConnection.Cl ose()
I have tried a few ways to do this but I always get an error:
"Update requires a valid InsertCommand when passed DataRow collection with
new rows."
Any ideas? Any help gratefully received.
Mark
This is my first attempt to update an access database in VB.Net 2005. It
goes broadly as follows (I have condensed it):
Dim MyConnection As New Data.OleDb.OleD bConnection
MyConnection.Co nnectionString = ("Provider=Micr osoft.Jet.OLEDB .4.0;
Data Source=c:\books .mdb")
Dim Myadaptor As OleDb.OleDbData Adapter
Myadaptor = New OleDb.OleDbData Adapter("select * from stockitems",
MyConnection)
Dim MyDataSet As New DataSet
MyConnection.Op en()
Myadaptor.Fill( MyDataSet)
Dim newRow As DataRow = MyDataSet.Table s(0).NewRow
newRow("code") = "New Code"
MyDataSet.Table s(0).Rows.Add(n ewRow)
Myadaptor.Updat e(MyDataSet)
MyConnection.Cl ose()
I have tried a few ways to do this but I always get an error:
"Update requires a valid InsertCommand when passed DataRow collection with
new rows."
Any ideas? Any help gratefully received.
Mark
Comment