Sunday, March 16, 2014

Display Records using VB6 and MS Access

This tutorial will teach you how to display records from MS Access to Visual Basic 6.

We will use Data Grid to store information from our database.

CODES FOR MODULE1
========================================================================
Option Explicit

Public con As ADODB.connection
Public ado As ADODB.Recordset
________________________________________________________________
Public Sub connection()
Set con = New ADODB.connection
con.CursorLocation = adUseClient
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\Database1.mdb"
con.Open
End Sub
=================================================================
CODES FOR FORM1

Option Explicit
________________________________________________________________
Private Sub Form_Load()
Module1.connection
On Error Resume Next
Set ado = New ADODB.Recordset
ado.Open "Select * From Table1", con, adOpenStatic, adLockPessimistic
Set DataGrid1.DataSource = ado
End Sub
=================================================================

CLICK HERE TO DOWNLOAD THE SOURCE CODE

No comments:

Post a Comment