We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,220 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

compile error in connecting database

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
3
Contributors
2
Replies
14 Hours
Discussion Span
9 Months Ago
Last Updated
3
Views
johncornelius23
Newbie Poster
4 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

BitBlt
Practically a Posting Shark
894 posts since Feb 2011
Reputation Points: 482
Solved Threads: 148
Skill Endorsements: 14

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

QVeen72
Veteran Poster
1,017 posts since Nov 2006
Reputation Points: 118
Solved Threads: 164
Skill Endorsements: 5

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0581 seconds using 2.64MB