I am using OLEDB in VB.NET 2013 to create an interface for an Access2010 database.
All of my tables have autonumber primary keys. Each of my forms updates only one table at a time.
Several of my forms work well but two do not. The code is consistent for all the forms.
For the two that do not work, the DataTable has the correct updates going into the Form_Closing but the Update indicates no records updated and the data source does not change. No exception is thrown. I have searched but cannot find where else to look for WHY. Since the method works with several other tables, I know the method is basically ok. But there is probably something about these tables specifically. I am looking for help finding out WHY it is not updating and is giving me no feedback.
Dim Db As New OleDb.OleDbConnection
Dim da As OleDb.OleDbDataAdapter
Dim PumpStat As DataTable
in the Form_Load
Db.ConnectionString = PFloSupport.FileConnectString1
Db.Open()
da = New OleDbDataAdapter("SELECT * FROM Pump Order by PumpName;", Db)
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
Dim cb As New OleDb.OleDbCommandBuilder(da)
da.UpdateCommand = cb.GetUpdateCommand(True)
PumpStat = New DataTable : da.Fill(PumpStat)
....users make changes to the DataTable
in Form_Closing
Dim Num As Integer = 0
Try
Num = da.Update(PumpStat)
Catch ex As OleDbException
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
Db.Close()
All of my tables have autonumber primary keys. Each of my forms updates only one table at a time.
Several of my forms work well but two do not. The code is consistent for all the forms.
For the two that do not work, the DataTable has the correct updates going into the Form_Closing but the Update indicates no records updated and the data source does not change. No exception is thrown. I have searched but cannot find where else to look for WHY. Since the method works with several other tables, I know the method is basically ok. But there is probably something about these tables specifically. I am looking for help finding out WHY it is not updating and is giving me no feedback.
Dim Db As New OleDb.OleDbConnection
Dim da As OleDb.OleDbDataAdapter
Dim PumpStat As DataTable
in the Form_Load
Db.ConnectionString = PFloSupport.FileConnectString1
Db.Open()
da = New OleDbDataAdapter("SELECT * FROM Pump Order by PumpName;", Db)
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
Dim cb As New OleDb.OleDbCommandBuilder(da)
da.UpdateCommand = cb.GetUpdateCommand(True)
PumpStat = New DataTable : da.Fill(PumpStat)
....users make changes to the DataTable
in Form_Closing
Dim Num As Integer = 0
Try
Num = da.Update(PumpStat)
Catch ex As OleDbException
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
Db.Close()