I am attempting to use VB2008 Express to Display, Edit, and Append an Access database. I can display information fine, but for some reason updating the database is posing an issue. The code below runs fine and doesn't throw any exceptions. However the Access database itself does not update. When I physically open the table in Access, the field I am attempting to change remains empty. Furthermore, when I try to display the changed field in a label (the very last two lines) I get a discrepency between what is in the data set and my dbrow object despite filling the data set and setting the dbrow = data set. For some reason label30 displays the information that I want while label13 remains blank.
Any assistance will be greatly appreciated, as I have spent the last two days in forums just to get this far. I am an intermediate vb user (though new to .net), I am a novice with db applications, and new to this forum so please be gentle. Thank you in advance.
'Update record. Try Con.Open() Adapter = New OleDbDataAdapter("Select * from Machines", Con) Builder = New OleDbCommandBuilder(Adapter) Adapter.Fill(DS) DS.Tables("Machines").Rows.Item(clickedindex).Item(56) = UserName DS.AcceptChanges() Builder.GetUpdateCommand() Adapter.Update(DS, "Machines") Adapter.Dispose() DS.Dispose() Con.Close() Catch ex As Exception MsgBox(ex.ToString) End Try 'Retrieve updated record and display. Try Con.Open() Adapter = New OleDbDataAdapter("Select * from Machines", Con) Adapter.Fill(DS) dbRow = DS.Tables("Machines").Rows.Item(SearchResults(clickedindex)) Adapter.Dispose() Con.Close() Catch ex As Exception MsgBox(ex.ToString) End Try frmMachDisplay.Label13.Text = DS.Tables("Machines").Rows.Item(clickedindex).Item(56).ToString frmMachDisplay.Label30.Text = dbRow(56).ToString