Question Locked

connectivity of VB6 and MS Access

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
i want to connect vb6 form to a ms access databse based on a query. how can i do so

4 replies

by 3xp3rt

In your VB6 project open DataEnvironment (add DataEnvironment from Project menu Add Data Environment) In this window you can see the Connection (usually Connection1) Right Click on Connection, and click on Properties. From Properties windows select Connection, select Build Connection string and the connection is done.

by royeschner

'declare in Module - sub Main()
Public gstrConnectionString As String

gstrConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\MyDB.mdb";Persist Security Info=False"
''''''''''''''''''''''''''''''''''''''''
'assign global connection string to the connection
Set cn = New ADODB.Connection
cn.ConnectionString = gstrConnectionString
cn.Open

'recordset processing
Dim alphaRS As ADODB.Recordset
Dim strQuery As String

Set alphaRS = New ADODB.Recordset

strQuery = "Select * From TableName WHERE Enabled=True"

alphaRS.Open strQuery, cn, adOpenKeyset, adLockOptimistic

This discussion is closed to new replies.