Updating Records in MS Access Using VB.Net

Updating Records in MS Access Using VB.Net

This tutorial is all about Updating Records in MS Access Using VB.Net. In this post i will teach you on Updating Records in MS Access Using VB.Net. So let’s get started:

As a continuation of this tutorial. We will use the Displaying Data Table Records in Datagridview using VB.Net

  • First, Design your Form like this one below.
    Add another Button. Name it “Update

  • After designing the form. Click the Update Button and add this following codes.


Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Sql = “UPDATE tblitems SET ITEMNAME='” & TextBox1.Text & “‘,BRAND= ‘” & TextBox2.Text & “‘, ” & _
” PRICE='” & TextBox3.Text & “‘ WHERE ID = ” & Me.Text
With dbcmd
.CommandText = Sql
.Connection = Myconnection
End With

result = dbcmd.ExecuteNonQuery
If result > 0 Then
MsgBox(“New Record has been Updated!”)
Call Button1_Click(sender, e)

MsgBox(“No Record has been Updated!”)
End If

Catch ex As Exception

End Try
End Sub


  • After that, Add this following Sub in the Public Class Form1.[vbnet]
    Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
    Me.Text = DataGridView1.CurrentRow.Cells(0).Value.ToString
    TextBox1.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString
    TextBox2.Text = DataGridView1.CurrentRow.Cells(2).Value.ToString
    TextBox3.Text = DataGridView1.CurrentRow.Cells(3).Value.ToString
    End Sub
  • Then Click F5 to Run the Program.

If you have any comments or suggestions about on Updating Records in MS Access Using VB.Net, please feel free to contact our webpage.

Download Updating Records in MS Access Using VB.Net Here

Other Articles Readers might read:

Leave a Comment