VB 6.0 - MS Access 2007 (accdb) Connection

This Tutorial Visual Basic 6.0 how to connect Database MS Access 2007 (.accdb)
  • Step 1: Create database and tabel in MS Access 2007
  • Step 2 : Design form in VB 6.0

#Step 1 :
Create Folder VB6Access2007
Create Database use MS Access 2007 inside Folder VB6Access2003
Database name : DB.accdb
Table name : tbl_product
design table like below picture :

fill sample product

#Step 2 :
Open Visual Basic 6.0
Satandard EXE - Open
Add component
Click Apply - OK
Design Form1 like below picture
Click Project - Preferences

 checklist : Microsoft Access 11.0 Object Library
save your project inside Folder VB6Access2007
click here for VB 6.0 - MySQL Connection
and then place code below in form1 :
Dim Conn As New ADODB.Connection
Dim RSProduct As ADODB.Recordset
Sub OpenDB()
Set Conn = New ADODB.Connection
Set RSProduct = New ADODB.Recordset
Conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & App.Path & "\DB.accdb"
End Sub
Private Sub Form_Load()
Call OpenDB
Adodc1.ConnectionString = Conn
Adodc1.RecordSource = "TBL_PRODUCT"
Set DataGrid1.DataSource = Adodc1
End Sub
Result :

You can click here to download project above (source code)

Subscribe to receive free email updates:

0 Response to "VB 6.0 - MS Access 2007 (accdb) Connection"

Post a Comment