Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / October 2007

Tip: Looking for answers? Try searching our database.

Help with ADO connection string - Access 2007

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Corta - 17 Oct 2007 20:14 GMT
Hello, I need help getting the ADO connection string syntax right for
my Access 2007 Db application.  Below is my code.  My backend
database
file is located at "f:\data\mydb.accdb".  I basically need to replace
the "Data Source" argument with the hard path to my database in the
strConnection setup.

Thanks for your help.

Corta

Sub RecordCount()

Dim cnCh5 As ADODB.Connection
Dim rsContacts As ADODB.Recordset
Dim strConnection As String

strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
               "Data Source=" & CurrentProject.Path &
"\Ch5CodeExamples.accdb;"

'create a new connection instance and open it using the connection
string
Set cnCh5 = New ADODB.Connection
cnCh5.Open strConnection

'create a new instance of a recordset
Set rsContacts = New ADODB.Recordset
'set various properties of the recordset
With rsContacts
   .CursorType = adOpenStatic
   'open the recordset based on tblContacts table using the existing
connection
   .Open "tblContacts", cnCh5
End With

'print the number of records to the Immediate Window
Debug.Print "The total number of records is: " &
rsContacts.RecordCount

'close the database connection
cnCh5.Close

'set the recordset and connection to nothing
Set rsContacts = Nothing
Set cnCh5 = Nothing

End Sub
Douglas J. Steele - 17 Oct 2007 20:44 GMT
You mean

strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
               "Data Source=f:\data\mydb.accdb;"

?

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Hello, I need help getting the ADO connection string syntax right for
> my Access 2007 Db application.  Below is my code.  My backend
[quoted text clipped - 44 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.