VB 6.0 - How to connect Access 2007 Database (.accdb)

In this tutorial, we'll share about How to connect Access 2007 Database ( .accdb ).

Create database : DBTM.accdb
Create Tabke : TBL_CUSTOMER
Design TBL_CUSTOMER like below picture



Create Folder with name : VB6 Access 2007
Fill your database ( DBTM.accdb ) to folder above

Open your VB 6.0 Application
Standard EXE - Open

Click Project - References

Click OK
Design Form1 like below picture



Place code below to Form1
Dim Conn As New ADODB.Connection
Dim RSCustomer As ADODB.Recordset
Sub OpenDB()
Set Conn = New ADODB.Connection
Set RSCustomer = New ADODB.Recordset
Conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & App.Path & "\DBTM.accdb"
End Sub
Private Sub Form_Load()
Call OpenDB
Adodc1.ConnectionString = Conn
Adodc1.RecordSource = "TBL_CUSTOMER"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub

Save your project to folder VB6 Access 2007
and the last, you can run your project
Below for the result

Related Posts :

0 Response to "VB 6.0 - How to connect Access 2007 Database (.accdb)"