Problems Updating Access Table

  • Thread starter Thread starter Octavius Khan
  • Start date Start date
O

Octavius Khan

I'm fairly new to VB.Net 2005 development and I am in need of updating MS
Access 2000 data via code. This was easy to do in my prior programming
language, but I am stuck here. :(

I am using the following test code that when a button is pushed, the
contents of the Customer_ID field is changed. Well, it does change. I have
a datagrid on Windows Form connected to an Access database and the chage
occurs, but is not saved. When I exit the program and re-run it, the old
data remains.

Thanks for any assistance.

Private Sub btn_GetCustomerInfo_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btn_GetCustomerInfo.Click

Dim MyData As DataRow

Dim MyString As String

MyData = ds_Binding.Tables(0).Rows(CARES_BindingSource.Position)

MyString = MyData("Customer_ID")

MessageBox.Show(MyString)

'Change It's Value

MyData("Customer_ID") = "123456789"

MyData.AcceptChanges()

End Sub
 
I think I saw this posted somewhere else, but I'm not sure, so I'm going to
give you a quick answer.

Calling AcceptChanges removes the "marks" behind the scenes in the dataset
that tells it which records have been modified.

To do an update, you need to call the Update method on the Data Adapter or
Table Adapter you used to fill the dataset or DataTable. It will update any
rows that are marked as new, deleted, or changed.

Robin S.
 
Thanks, Robin.

RobinS said:
I think I saw this posted somewhere else, but I'm not sure, so I'm going to
give you a quick answer.

Calling AcceptChanges removes the "marks" behind the scenes in the dataset
that tells it which records have been modified.

To do an update, you need to call the Update method on the Data Adapter or
Table Adapter you used to fill the dataset or DataTable. It will update
any rows that are marked as new, deleted, or changed.

Robin S.
 
Back
Top