Hi Jason,
The answer is why it is not updating is is simple, however why that strange
closing code.
In my opinion it is even better to open an access database at the begin of
the program and to close it at the end. That prevent users from moving the
mdb file in the maintime (this is only for access).
The closing statement is strange, where did you read that, after all is
working it is better to place all in a try, catch finally end try block.
However because the sentence above you do not need a finally.
The answer on why it is not updating is simple, you fill the dataset with
old information before you do the update so what you have entered in the
datagrid will be disapeared.
You probably need more code however first delete the sentence I point you on
in this procedure and better change it in a good way.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim cn As New OleDbConnection(ConnString)
cn.Open()
Dim da As New OleDbDataAdapter("SELECT DCN,Field1 from Table1", cn)
Dim ds As New DataSet
Dim cmdBuilder As OleDbCommandBuilder = New OleDbCommandBuilder(da)
da.Fill(ds, "Table1")
This one above fills the dataset again with the old data from the datagrid
so you have to remove this.
' Update database with modified data
da.ContinueUpdateOnError = True
This one is a killer I would replace this with a Try, Catch and EndTry block
like this.
(This as well in the button1 at the fill, I show you the most simple one)
da.UpdateCommand = cmdBuilder.GetUpdateCommand() Try
da.Update(ds, "Table1")
Catch ex as OleDbexception
messagebox.show(ex.tostring)
'this has to be if it is good in an if block where you do your
actions when there is an error
End Try
This is absolute not complete, however to give you a go.
(all typed in this message so watch typos or other errors)
I hope this helps?
Cor