Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2003, 09:49 PM
Authorized User
 
Join Date: Jul 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADODB Connection String

I am trying to build an ADODB Connection, and I have a few questions about the connection string.

1. Since I am developing this in Access 2000, and the code is in the Access 2000 project I am working on, why do I have to provide a hardcoded path to my database in the connection string?

2. If I really to have to hardcode the database path, is there a way to make Access get the path? I am developing on a different machine that it will be running on and I would hate to have to hardcode the path. Even if I did, there is no way to ensure that my customer won't reorganize her directories, and break it. There has to be a better way.

Thanks for your insight,
Quint
 
Old September 29th, 2003, 10:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Jut use:

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strSQL As String

strSQL = "SELECT Field FROM Table

Set cnn = CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open strSQL, cnn

The Connection property of the CurrentProject object returns a reference to the CurrentProject's ADO Connection object and its related properties.

HTH,

Bob



 
Old September 30th, 2003, 06:30 AM
Authorized User
 
Join Date: Jul 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the info. I was trying to use the CurrentProject object, but didn't try CurrentProject.Connection. Sometimes when I start to get frustrated with a problem, the simplest things will escape me. That's when it's time to shutdown the computer and take a break.

Thanks again,
Quint






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP / ADODB - How to close connection? hamproof Classic ASP Databases 4 August 24th, 2007 01:43 PM
Help.Can i use ADODB.Connection with DetailsView? aekta ASP.NET 2.0 Professional 5 March 11th, 2007 06:08 AM
ADODB.Connection on every page? Steve777 Classic ASP Professional 10 September 13th, 2006 08:19 AM
ADODB.Connection (0x800A0E7A) sumanst Classic ASP Databases 1 August 5th, 2005 02:56 PM
ADODB connection for Recordset dpatole Beginning VB 6 1 October 14th, 2003 04:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.