G
Guest
Hello all,
I am using ADO.NET and trying to update the MsAccess database but
unable to do so.
Here is the code below that I used.
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim sql As String
Connect()
sql = "select key, title from tblISBN"
ds = New DataSet
da = New OleDbDataAdapter(sql, conn)
da.Fill(ds, "tblISBN")
TextBox1.DataBindings.Add("Text", ds, "tblISBN.title")
TextBox2.DataBindings.Add("Text", ds, "tblISBN.key")
ds.Tables(0).Constraints.Add("PK", ds.Tables(0).Columns(0),
True)
End Sub
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSave.Click
Dim cb As OleDbCommandBuilder
cb = New OleDbCommandBuilder(da)
Try
da.UpdateCommand = cb.GetUpdateCommand
da.Update(ds, "tblISBN")
Me.BindingContext(ds, "tblISBN").EndCurrentEdit()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
It updates the database but when I check the actual msaccess database
file, the data is not updated in that.
Any help will be beneficial.
Thanking You,
Regards,
Vibhu.
I am using ADO.NET and trying to update the MsAccess database but
unable to do so.
Here is the code below that I used.
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim sql As String
Connect()
sql = "select key, title from tblISBN"
ds = New DataSet
da = New OleDbDataAdapter(sql, conn)
da.Fill(ds, "tblISBN")
TextBox1.DataBindings.Add("Text", ds, "tblISBN.title")
TextBox2.DataBindings.Add("Text", ds, "tblISBN.key")
ds.Tables(0).Constraints.Add("PK", ds.Tables(0).Columns(0),
True)
End Sub
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSave.Click
Dim cb As OleDbCommandBuilder
cb = New OleDbCommandBuilder(da)
Try
da.UpdateCommand = cb.GetUpdateCommand
da.Update(ds, "tblISBN")
Me.BindingContext(ds, "tblISBN").EndCurrentEdit()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
It updates the database but when I check the actual msaccess database
file, the data is not updated in that.
Any help will be beneficial.
Thanking You,
Regards,
Vibhu.