Hello,
I am trying to update a table based on row selected in a grid (C1TrueDBGrid1.Columns(1).Value), but I am getting the following error:
Update unable to find TableMapping['Table'] or Data Table 'Table'
Can you please help me locate the error in my code.
Code:
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\AOPT2002org.mdb;Persist Security Info=True;Jet OLEDB
atabase Password=testaopupdate"
Dim objConnection As New OleDb.OleDbConnection(ConnectionString)
Dim objDataAdapter As New OleDb.OleDbDataAdapter("select * from AOP5", objConnection) 'where country in(SELECT COUNTRY FROM AOP5 WHERE SN like " & "'" & result & "'" & ")order by country", objConnection)
'dataset object
Dim objDataSet As New DataSet
'fill dataset
objConnection.Open()
'************************************
objDataAdapter.Fill(objDataSet, "Chapter")
MsgBox(C1TrueDBGrid1.Columns(1).Value)
Try
objDataAdapter.Update(objDataSet)
objDataAdapter.SelectCommand.CommandText = ("INSERT INTO AOP5(NSN) VALUES('" & C1TrueDBGrid1.Columns(1).Value & "')")
objDataSet.Clear()
objDataAdapter.Update(objDataSet)
objDataAdapter.Fill(objDataSet)
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
Thanks,
Products used ACCESS 2003, VS 2008.
Victor
I am trying to update a table based on row selected in a grid (C1TrueDBGrid1.Columns(1).Value), but I am getting the following error:
Update unable to find TableMapping['Table'] or Data Table 'Table'
Can you please help me locate the error in my code.
Code:
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\AOPT2002org.mdb;Persist Security Info=True;Jet OLEDB
Dim objConnection As New OleDb.OleDbConnection(ConnectionString)
Dim objDataAdapter As New OleDb.OleDbDataAdapter("select * from AOP5", objConnection) 'where country in(SELECT COUNTRY FROM AOP5 WHERE SN like " & "'" & result & "'" & ")order by country", objConnection)
'dataset object
Dim objDataSet As New DataSet
'fill dataset
objConnection.Open()
'************************************
objDataAdapter.Fill(objDataSet, "Chapter")
MsgBox(C1TrueDBGrid1.Columns(1).Value)
Try
objDataAdapter.Update(objDataSet)
objDataAdapter.SelectCommand.CommandText = ("INSERT INTO AOP5(NSN) VALUES('" & C1TrueDBGrid1.Columns(1).Value & "')")
objDataSet.Clear()
objDataAdapter.Update(objDataSet)
objDataAdapter.Fill(objDataSet)
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
Thanks,
Products used ACCESS 2003, VS 2008.
Victor