Want to connect Access 2007 to SQL Server 2008

Hi Everybody,

I am trying to connect my Access 2007 database to a SQL Server  2008 database. I have tried the following string that I found, but it is not working.
---------------------------------------------------------------------------------------------------
Private Sub Command0_Click()

Dim MyConnObj As New ADODB.Connection    <--- Problem highlighted in yellow here
Dim myRecSet As New ADODB.Recordset
Dim sqlStr As String

MyConnObj.Open _
 "Provider = sqloledb;" & _
 "Data Source=timvmsql1;" & _
 "Initial Catalog=TESTWORLD;"


   sqlStr = "select * from contacts"

   myRecSet.Open sqlStr, MyConnObj, adOpenKeyset

   MsgBox "Total Number of records = " & myRecSet.RecordCount


End Sub
---------------------------------------------------------------------------------------------

It does not seem to recognize the ADODB functionality. Is there somewhere that I need to enable this functionality or is there another method?  Perhaps DAO?

Thanks,
jonsuns7Asked:
Who is Participating?
 
Jeffrey CoachmanMIS LiasonCommented:
Do you have the ADO library loaded as a reference in your VBE?

Tools-->References-->
0
 
jonsuns7Author Commented:
I had figured out the answer, that was the same as you mentioned. But since nobody else answered, I'll give you the points. Have a good weekend.
0
 
Jeffrey CoachmanMIS LiasonCommented:
ok
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.