Why the source database not updated?

  • Thread starter Thread starter CM
  • Start date Start date
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
 
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
 
Back
Top