Tuesday, 14 February 2017

How to create a connection with the help of ADODB reference?

1. Open Standard.EXE from New Project window->go to project menu->References-> Select Microsoft ActiveX Data Object 2.5 library->OK

2. Write the following code on the General Section
          Dim cn As ADODB.Connection
          Dim rs As ADODB.Recordset

3. Write the following code in Form_Load() Section

   Private Sub Form_Load()

      Set cn = New ADODB.Connection -------> Create an object of Connection
      Set rs = New ADODB.Recordset ---------->Create an object of Recordset

cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
              Source=C:\Users\786\Desktop\Student_Database.mdb;Persist Security Info=False"
cn.Open
rs.Open "Student_Info", cn, adOpenDynamic, adLockOptimistic, adCmdTable


   End Sub

No comments:
Write comments