ADO.NET with ACCESS
for VB.net guys

 

Declare these Variables

Dim bm As BindingManagerBase

Dim unam As String

Dim d1 As DataRow

Dim datatable1 As DataTable

 

Private Sub Form1_Load(ByVal sender..)

        OleDbDataAdapter1.Fill(DataSet11, "CustomerDetails")

        bm = Me.BindingContext(DataSet11, "CustomerDetails")

End Sub

Sub write(ByVal choice As Boolean)

        txt1.ReadOnly = choice

        txt2.ReadOnly = choice

        txt3.ReadOnly = choice

        txt4.ReadOnly = choice

End Sub

Private Sub ADD_Click(ByVal sender…)

If MsgBox("Are you suggest", MsgBoxStyle.YesNo, "Add") = MsgBoxResult.No Then Exit Sub

write(False)

bm.AddNew()

End Sub

 

Private Sub SAVE_Click(ByVal sender..) Handles Button2.Click

unam = txt1.Text

    Try

       If txt1.Text = "" Then

MsgBox("Number can't take null value", MsgBoxStyle.OKOnly, "MATRIX")

            Else

                datatable1 = DataSet11.Tables("Customerdetails")

                d1 = datatable1.Rows.Find(unam)

              If Not d1 Is Nothing Then

MsgBox("This Number Already exit", MsgBoxStyle.OKOnly, "MATRIX DEMO")

                    txt1.Clear()

                Else

         bm.EndCurrentEdit()

         OleDbDataAdapter1.Update(DataSet11, "CustomerDetails")

MsgBox("RECORD HAS BEEN SUCESSFULLY ADDED" MsgBoxStyle.OKOnly,"MATRIX")

                End If

            End If

        Catch

MsgBox("This Number Already exit", MsgBoxStyle.OKOnly, "MATRIX DEMO")

        End Try

End Sub

 

Private Sub EDIT_Click(ByVal sender..) Handles Button3.Click

 write(False)

If MsgBox("DO YOU LIKE TO EDIT ? ", MsgBoxStyle.YesNo, "Edit") = MsgBoxResult.No Then Exit Sub

bm.EndCurrentEdit()

OleDbDataAdapter1.Update(DataSet11, "CustomerDetails")

End Sub

 

Private Sub DELETE_Click(ByVal sender..) Handles Button4.Click

If MsgBox("ARE YOU SURE REMOVE RECORDS ? ", MsgBoxStyle.YesNo, "Delete") = MsgBoxResult.No Then Exit Sub

bm.RemoveAt(bm.Position)

OleDbDataAdapter1.Update(DataSet11, "CustomerDetails")

End Sub

 

DATA NAVIGATIONS

    Private Sub First_Click(ByVal sender..) Handles Button5.Click

        bm.Position = 0

    End Sub

 

    Private Sub Previous_Click(ByVal sender..) Handles Button6.Click

        bm.Position -= 1

    End Sub

 

    Private Sub Next_Click(ByVal sender…) Handles Button7.Click

        bm.Position += 1

    End Sub

 

    Private Sub Last_Click(ByVal sender…)Handles Button8.Click

       bm.Position = DataSet11.Tables("Customerdetails").Rows.Count - 1

    End Sub