Connect VB6 to MSAccess

0

I created a database in MSAccess and created a connection module. However, when the execute gives connection error. Does anyone have another example of how to connect VB6 to MSAcess?

My module code:

Option Compare Database

Option Explicit
Public T As Connection
Public c As Recordset

Private Sub conexao()
    Set T = creatobject("adodb.connection")
    Set c = creatobject("adodb.recordset")
    T.OpenRecordset " provider = microsoft.jet.oledb.4.0;datasource = " + app.Path & "\alex.mdb"
End Sub

Private Sub desconexao()
    Set T = Nothing
    Set c = Nothing
End Sub
    
asked by anonymous 04.06.2014 / 14:29

1 answer

1

Your connection function should be:

Private Sub conexao()
    Set T = creatobject("adodb.connection")
    Set c = creatobject("adodb.recordset")
    connString = microsoft.jet.oledb.4.0;datasource = " + app.Path & "\alex.mdb"
    T.Open connString // Abre a ligação para a base de dados
End Sub

Only after opening the connection with T.Open will you be able to perform operations on the DB.

    
04.06.2014 / 15:26