Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error white updating records

Status
Not open for further replies.

vcharles

IS-IT--Management
Jun 29, 2004
21
0
0
US
Hello,

I am getting the following error message at daaop5.Update(ds).

Update unable to find TableMapping['Table'] or DataTable 'Table'.

Any ideas what's causing the error?

Thanks

Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\aop29.mdb"
Dim objConnection As New OleDb.OleDbConnection(ConnectionString)
Dim sql As String = "Select * from Customer"
Dim daaop5 As New OleDb.OleDbDataAdapter(sql, objConnection)
Dim cmdb As New OleDbCommandBuilder(daaop5)

Dim ds As New DataSet()
daaop5.Fill(ds, "Customer")
daaop5.Update(ds, "Customer")
C1TrueDBGrid1.AllowAddNew = True
daaop5.SelectCommand.CommandText = ("INSERT INTO Customer(Description) VALUES('" & C1TrueDBGrid1.Columns(0).Value & "')")
ds.Clear()
daaop5.Update(ds) ----Error Line
daaop5.Fill(ds)
 
Not sure this will help but
Code:
daaop5.[COLOR=red]InsertCommand.CommandText[/color] = ("INSERT INTO Customer(Description) VALUES('" & C1TrueDBGrid1.Columns(0).Value & "')")


Zameer Abdulla
 
Sorry, it didn't work, It gives me the folowing error message.

Object reference not set to an instance of an object.

Victor
 
First, you don't need to update a DataAdapter unless you make changes. Now for the actual error you can't update a DataAdapter with an empty DataSet because there is nothing to update.

Code:
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\aop29.mdb"
Dim objConnection As New OleDb.OleDbConnection(ConnectionString)
Dim sql As String = "Select * from Customer"
Dim daaop5 As New OleDb.OleDbDataAdapter(sql, objConnection)
Dim cmdb As New OleDbCommandBuilder(daaop5)

Dim ds As New DataSet()
daaop5.Fill(ds, "Customer")
daaop5.Update(ds, "Customer")
C1TrueDBGrid1.AllowAddNew = True
daaop5.SelectCommand.CommandText = ("INSERT INTO Customer(Description) VALUES('" & C1TrueDBGrid1.Columns(0).Value & "')")
ds.Clear() [red]<---Bad if before update[/red]
daaop5.Update(ds) ----Error Line
daaop5.Fill(ds)
What exactly are you wanting to do?

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Hello,

Thanks for pointing out the bad code. I would like to enter multiple data in a grid and save all all the rows entered to a dadabase.


Victor

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top