1
Thanks

A few words of thanks would be greatly appreciated.

How to connect VB 6.0 to MS Access 2003

Programs written in Visual Basic 6.0 can access Microsoft Access 2003 databases. Knowledge of programming elements, such as functions and loops, and knowledge of databases and SQL is required to write effective code in Microsoft Visual Basic to connect to Microsoft Access 2003 databases. The ADODB object can create a connection to Microsoft Access 2003 databases. The database records can be accessed with the ADODB.recordset API. The Open() interface is used to create and access the records of the Microsoft Access 2003 database. SQL may be used to perform operations such as searching the database for matching information.



Issue

Can someone explain to me how to connect VB6.0 to MS Access 2003?

Solution

In the General Declaration Area paste this:

Dim cn As New ADODB.Connection   
Dim rs As New ADODB.Recordset
(in Form's Activate Event)
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=EMP.mdb;Persist Security Info=False"
cn.Open
rs.Open "select Eid,Ename,ppfSub,Basic From EmpData Order By Eid", cn, adOpenStatic, adLockPessimistic
Text1.text=rs.Fields(0)
etc

Note

Thanks to ajit for this tip on the forum.
1
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Published by . Latest update on by Olivia Long.

This document, titled "How to connect VB 6.0 to MS Access 2003," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments