Updating a record in an Access database

J Trahair

Well-known member
Joined
May 14, 2008
Messages
175
Location
Spain
Programming Experience
10+
I am trying to edit a record found in the database as follows:
VB.NET:
        Dim objDs As DataSet
        Dim ObjDa As OleDbDataAdapter
        Dim objRow As DataRow
        Dim objTable As DataTable
        Dim objColumn As DataColumn
        mstrSQL = "SELECT * FROM ItemsSold WHERE ProductCode = 'T468' AND Colour = 'Blue'"
        objDs = New DataSet()
        ObjDa = New OleDbDataAdapter(mstrSQL, mstrOLEConnectionString)
        ObjDa.Fill(objDs, "ItemsSold")

         MsgBox(objDs.Tables(0).Rows(0).Item("UnitPrice"))
         MsgBox(objDs.Tables(0).Rows(0).Item("RecNo"))
         'These message boxes show the data correctly.

         objDs.Tables(0).Rows(0).Item("UnitPrice") = 19.60 'New price of the T468
         ObjDa.Update(objDs, 0)  <<<<<<<< error message:
Update unable to find TableMapping['0'] or DataTable '0'.
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at LearnWinForm.frmTextBoxesAndComboboxes.Button3_Click(Object sender, EventArgs e) in C:\My Documents\NET Blank\LearnWinForm\TextboxesAndComboboxes.vb:line 284
Please can you tell me what I've (not) done. Thank you.
 
Must you make a new thread for every iteration of the same problem you have? Please use the post Reply button more often
 
Back
Top