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(odaTestTa ble). 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(dsTestTa ble)
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(dsTest Table)
Catch ex As Exception
Dim x As String = ex.Message
End Try
End Sub
End Class
I used Access to create a simple database with one table (TestTable).
I then created a test application (OLETest) and added a OLEdbDataAdapter(odaTestTa
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(dsTestTa
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(dsTest
Catch ex As Exception
Dim x As String = ex.Message
End Try
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
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!
You could test this, by doing this:
Dim dt As DataTable = dsTestTable.Tables(0).GetC
For Each row As DataRow in dt.Rows
Debug.WriteLine(row.RowSta
Next row
The row state should be 'Added' for new records.
Bob