VB 6.0 - MS Access 2003 (mdb) Connection

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

#Step 1 :
Create Folder VB6Access2003
Create Database use MS Access 2003 inside Folder VB6Access2003
Database name : db.mdb
Table name : tbl_product
design table like below picture :

fill sample product


#Step 2 :
Open Visual Basic 6.0
Standard EXE - Open
Add component
Click Apply - OK
Design Form1 like below picture
save your project inside Folder VB6Access2003

click here for VB 6.0 - MS Access 2007 (accdb) 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.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB.mdb"
End Sub
Private Sub Form_Load()
Call OpenDB
Adodc1.ConnectionString = Conn
Adodc1.RecordSource = "TBL_PRODUCT"
Adodc1.Refresh
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 2003 (mdb) Connection"

Post a Comment