Link to home
Start Free TrialLog in
Avatar of bobsegrest
bobsegrest

asked on

My OLEdb Update isn't working

I am trying to work with an Access database file in a new VB.Net Windows application.  

I used Access to create a simple database with one table (TestTable).

I then created a test application (OLETest) and added a OLEdbDataAdapter(odaTestTable).  Using the datapter I created a typed dataset (dsTestTable) and displayed it on my form using a datagrid.  I then added a button to call the dataadapter update routine.

When I run the test application I enter a new data row in the datagrid and press the Update button.  By stepping through the code I am able to see that the update command returns a value of 1, indicating that the update was completed and no exceptions are generated.

However if I exit and restart my application, the new row is not in the datatable.

What am I missing?

Bob


Here is the code.....

Public Class frmOLETest

    Private Sub frmOLETest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        odaTestTable.Fill(dsTestTable)
    End Sub

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        Dim I As Integer
        Try
            I = odaTestTable.Update(dsTestTable)
        Catch ex As Exception
            Dim x As String = ex.Message
        End Try
    End Sub
End Class
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

That doesn't explain any reasons why the update doesn't add any rows.

You could test this, by doing this:

Dim dt As DataTable = dsTestTable.Tables(0).GetChanges()

For Each row As DataRow in dt.Rows
   Debug.WriteLine(row.RowState.ToString())
Next row

The row state should be 'Added' for new records.

Bob
ASKER CERTIFIED SOLUTION
Avatar of Sancler
Sancler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bobsegrest
bobsegrest

ASKER

Thank you Roger!

Yes, this is a VS.2005 project.  What a bizarre default behavior!  I would have never found this one on my own...

Bob
Hi Guys!

Its Fixed! WooHoo! Many thanks to sancler for help on this. That link helped loads! Now I have a new problem that I am going to open a new question for as I think the points assigned to this question should go to their rightful owner!

Lee
Oops I posted on the wrong question aha! sorry!