Monday, 28 September 2015

How to Add,Update,Delete and Clear records in Database (Ms Access) with ...

How to add,Update ,Delete and Clear records in Ms Access Database using ADODC control -An Advanced Visual Basic Application (Step by step full tutorial with explanation of each step).

This tutorial is focused on following points.

* How to create a simple database with MS Access.

*How to add ADODC Control on the Visual Basic Toolbox.

*How to use the ADODC control and set the properties and establish database connection using Ms Access .

*How to set the properties of each fields according to database application.

*How to hide ADODC control.

*How to add Record navigation buttons i.e First,Previous,Next,Last.

*How to perform Database Operation i.e ADD Record,Delete Record,Update Record and Clear the records.



In this tutorial,every step is explained with supportive text within the video.so everyone can follow the steps to build such applications quite easily.

if you have any queries,suggestions or problems,please leave a comments.

Do share and Subscribe to my channel :-)









Source Code:


ADD RECORD:

Private Sub Addbtn_Click()

Studentdb.Recordset.AddNew

End Sub

CLEAR RECORD:

Private Sub cancelbtn_Click()

txtroll.Text = ""

txtname.Text = ""

txtclass.Text = ""

txtadd.Text = ""

txtemail.Text = ""

txtphone.Text = ""

End Sub

DELETE RECORD

Private Sub delbtn_Click()

confirmation = MsgBox("Do you want to delete this record", vbYesNo + vbCritical, "Delete Record Confirmation")

If confirmation = vbYes Then

Studentdb.Recordset.Delete

MsgBox "Record has been deleted Successfully", vbInformation, "Message"

Else

MsgBox "Record Not Delete !!!", vbInformation, "Message"

End If

End Sub

UPDATE RECORD:

Private Sub updatebtn_Click()

Studentdb.Recordset.Fields("RollNo") = txtroll.Text

Studentdb.Recordset.Fields("Name") = txtname.Text

Studentdb.Recordset.Fields("Class") = txtclass.Text

Studentdb.Recordset.Fields("Address") = txtadd.Text

Studentdb.Recordset.Fields("email") = txtemail.Text

Studentdb.Recordset.Fields("Phone") = txtphone.Text

Studentdb.Recordset.Update

MsgBox "data is saved successfully", vbInformation, "Message"

End Sub

EXIT APPLICATION

Private Sub exitbtn_Click()

Me.Hide

End Sub

FIRST NAVIGATION BUTTON

Private Sub firstbtm_Click()

Studentdb.Recordset.MoveFirst

End Sub

LAST NAVIGATION BUTTON

Private Sub lastbtn_Click()

Studentdb.Recordset.MoveLast

End Sub

NEXT NAVIGATION BUTTON

Private Sub nxtbtn_Click()

Studentdb.Recordset.MoveNext

End Sub

PREVIOUS NAVIGATION BUTTON

Private Sub prevbtn_Click()

Studentdb.Recordset.MovePrevious

End Sub