Question Cannot update

karthik1

New member
Joined
Jul 21, 2008
Messages
2
Programming Experience
Beginner
hello,

I am using VB.NEt 2005 and iam unable to update MS Access. here is the code ,
VB.NET:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click


        Dim cb As New OleDb.OleDbCommandBuilder(da)
    



        ds.Tables("Details").Rows(inc).Item(0) = IDTxt.Text
        ds.Tables("Details").Rows(inc).Item(1) = NameTxt.Text
        ds.AcceptChanges()
        da.Update(ds, "Details")
        MsgBox("data updated")

I am able to update the dataset but not see the changes in dbase.

the code wriiten in the form_load is,

VB.NET:
        Str = "Provider= Microsoft.Jet.OLEDB.4.0;"
        str &= "Data Source=C:\MutualFund1.mdb;"

        strconn = New OleDbConnection(Str)
        da = New OleDbDataAdapter("select * from Details ", str)

        Try
            da.Fill(ds, "Details")

        Catch ex As Exception

            MsgBox("No results Found")

        End Try

        MaxRows = ds.Tables("Details").Rows.Count
        inc = -1
Can anyone helpme out....
 
Last edited by a moderator:
Using the DataAdapter you are requesting for all records in your dataset that have changes (new records, modified, deleted) to be updated in the database.

Since you called the dataset.AcceptChanges you have changed the row state properties in all the records in your dataset, so there are now no changed records when you call your da.update.
 
Back
Top