Database not updated
Hi All,
What I simply want to do is just to add a record to a MS Access table. I have found out that the dataset has been updated but the changes didn't reflect in the database.
here is a piece of code that I used and failed.
Protected Const conString As String = _
" Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\AddressBook.mdb; User Id=; Password="
Dim cnn As New OleDbConnection(conString)
Dim da As New OleDbDataAdapter()
Dim ds As New DataSet
I have filled up the data adapter in the form load. After that the dataset is updated with the data from textboxes on button click event.
Dim dr As DataRow
dr = ds.Tables("Patron").NewRow()
dr.Item("PID") = Trim(txtPID.Text)
dr.Item("PName") = Trim(txtPName.Text)
ds.Tables("Patron").Rows.Add(dr)
BindingContext(ds).EndCurrentEdit()
ds.AcceptChanges()
da.Update(ds, "Patron")
I found out that the dataset is updated but it didnt' reflect to the database. I have binded the textboxes with the fileds from the table at design time from the properties.
Any help will be appreciated :(
|