whenever I try to run it I have a compile error in connecting my database this is my code

Dim con   As Adodb.Recordset
  Dim conn1   As Adodb.Connection
Private Sub mygdb()
        Set con = New Adodb.Connection
        con.CursorLocation = adUseClient
        con.Open "PROVIDER = Microsoft.Jet.OLEDB.4.0;Data Source =" & App.Path & "\enrolment.mdb;"
End Sub

Recommended Answers

All 2 Replies

You are trying to set the variable "con" to be a new connection. It is defined as a Recordset object.

Hi,

Change the code to:

Dim RS As New Adodb.Recordset
Dim con As New Adodb.Connection
Private Sub mygdb()
    Set con = New Adodb.Connection
    con.CursorLocation = adUseClient
    con.Open "PROVIDER = Microsoft.Jet.OLEDB.4.0;Data Source =" _
        & App.Path & "\enrolment.mdb;"
End Sub

Regards
Veena

commented: I'm still having an error +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.