Solved

Want to connect Access 2007 to SQL Server 2008

Posted on 2011-09-09
3
273 Views
Last Modified: 2012-05-12
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,
0
Comment
Question by:jonsuns7
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 36514349
Do you have the ADO library loaded as a reference in your VBE?

Tools-->References-->
0
 

Author Closing Comment

by:jonsuns7
ID: 36514969
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
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36515010
ok
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now