Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tod tod is offline
external usenet poster
 
Posts: 114
Default Connection Obect for Two Paths

I have a server that contains a database and a workbook.
The workbook code uses ADO to connect to the database, run
a query and return the results to the worksheet.

'Where cn is my ADODB.Connection
"cn.Open "Driver={Microsoft Access Driver
(*.mdb)};Dbq=C:\DatabasePath\DatabaseName.mdb;"

This works fine.

On another computer, I have a folder that is shared to
that folder on the server. I want to open the same
workbook from this shared folder and run the code. I'd
need to modify the statement to something like this:

'Where cn is my ADODB.Connection and V is the mapped drive
letter to DatabasePath.
"cn.Open "Driver={Microsoft Access Driver
(*.mdb)};Dbq=V:\DatabaseName.mdb;"

The problem is I'd like to have my code detect the path to
the database (depending from where I'm opening the
workbook) and set up the string accordingly.

Any suggestions?

tod


  #2   Report Post  
Posted to microsoft.public.excel.programming
Den Den is offline
external usenet poster
 
Posts: 16
Default Connection Obect for Two Paths

Use this instead... will work no matter what machine your on.

\\databaseserver\databasepath\databasename.mdb

Dennis

"Tod" wrote in message
...
I have a server that contains a database and a workbook.
The workbook code uses ADO to connect to the database, run
a query and return the results to the worksheet.

'Where cn is my ADODB.Connection
"cn.Open "Driver={Microsoft Access Driver
(*.mdb)};Dbq=C:\DatabasePath\DatabaseName.mdb;"

This works fine.

On another computer, I have a folder that is shared to
that folder on the server. I want to open the same
workbook from this shared folder and run the code. I'd
need to modify the statement to something like this:

'Where cn is my ADODB.Connection and V is the mapped drive
letter to DatabasePath.
"cn.Open "Driver={Microsoft Access Driver
(*.mdb)};Dbq=V:\DatabaseName.mdb;"

The problem is I'd like to have my code detect the path to
the database (depending from where I'm opening the
workbook) and set up the string accordingly.

Any suggestions?

tod




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
always recheck data connection library for latest connection strin FurmanGG Excel Discussion (Misc queries) 0 September 14th 07 04:48 PM
Paths Ross[_2_] New Users to Excel 1 April 4th 07 11:35 PM
I hate paths! Ross[_2_] Excel Discussion (Misc queries) 2 April 4th 07 10:14 PM
Help with filenames and paths. jim9912 Excel Discussion (Misc queries) 2 March 30th 06 05:52 PM
file paths hr Excel Discussion (Misc queries) 0 December 7th 05 04:59 PM


All times are GMT +1. The time now is 09:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"