Why the source database not updated?

C

CM

Hi there:
Following is the code, after change the Dataset, accepte the change made to the dataset and excute the update of Adapter, nothing happened to the database source database, what's wrong?
Thanks!
CM

-------------------------------------------------
Private Sub UpdateApartment()
Dim i As Integer
Dim myDataAdapter As OleDbDataAdapter
Dim myDataset As DataSet
Dim MyConnection As OleDbConnection

i = Session("intIndex")
myDataset = Session("tableApt")
myDataAdapter = Session("myAdapter")
MyConnection = Session("ADMConn")
With myDataset.Tables("Apt")
.Rows(i)("Company") = txtCompanyName.Text
.Rows(i)("BuildingName") = txtBuildingName.Text
End With

myDataset.AcceptChanges()
MyConnection.Open()
myDataAdapter.Update(myDataset)
MyConnection.Close()

End Sub
 
C

CM

Sorry, the above code result this error:

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

I changed the update code to:
myDataAdapter.Update(myDataset, "Apt")

The error is gone, but the source database still not updated.

CM





Hi there:
Following is the code, after change the Dataset, accepte the change made to the dataset and excute the update of Adapter, nothing happened to the database source database, what's wrong?
Thanks!
CM

-------------------------------------------------
Private Sub UpdateApartment()
Dim i As Integer
Dim myDataAdapter As OleDbDataAdapter
Dim myDataset As DataSet
Dim MyConnection As OleDbConnection

i = Session("intIndex")
myDataset = Session("tableApt")
myDataAdapter = Session("myAdapter")
MyConnection = Session("ADMConn")
With myDataset.Tables("Apt")
.Rows(i)("Company") = txtCompanyName.Text
.Rows(i)("BuildingName") = txtBuildingName.Text
End With

myDataset.AcceptChanges()
MyConnection.Open()
myDataAdapter.Update(myDataset)
MyConnection.Close()

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top