PC Review


Reply
Thread Tools Rate Thread

Relative path in database query connection string

 
 
DanL
Guest
Posts: n/a
 
      20th Feb 2009
I have a connection string that starts out like this:

DSN=Excel Files;DBQ=C:\Folder1\Folder2\Folder3\Filename.xls;

This is an absolute path, but I would like to use a relative path (i.e.
...\Filename.xls without the preceding path) instead. Is this possible?

In this case I am actually using this connection string within the
Filename.xls file. So what I would REALLY like is for the connection string
to refer to the path of the file that is using it. This way, if I save a
copy of the file Filename.xls as Filename2.xls, I don't have to change the
connection string and it will automatically point to Filename2.xls.
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      20th Feb 2009
The connection string is a String that you can modfiy like any string (DUH!)

from
Connection = "DSN=Excel Files;DBQ=C:\Folder1\Folder2\Folder3\Filename.xls;"

to
Folder = "C;\Temp\"
Connection = "DSN=Excel Files;DBQ=" & Folder & "Filename.xls;"



"DanL" wrote:

> I have a connection string that starts out like this:
>
> DSN=Excel Files;DBQ=C:\Folder1\Folder2\Folder3\Filename.xls;
>
> This is an absolute path, but I would like to use a relative path (i.e.
> ..\Filename.xls without the preceding path) instead. Is this possible?
>
> In this case I am actually using this connection string within the
> Filename.xls file. So what I would REALLY like is for the connection string
> to refer to the path of the file that is using it. This way, if I save a
> copy of the file Filename.xls as Filename2.xls, I don't have to change the
> connection string and it will automatically point to Filename2.xls.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Relative Path in Connection String Breunus Microsoft Excel Misc 2 29th Jul 2009 05:10 PM
how to judge whether a path is relative path or absolute path thinktwice Microsoft Windows 2000 CMD Promt 20 7th May 2008 11:06 PM
how can we change absolute path to relative path waseem hijazi via .NET 247 Microsoft ADO .NET 0 15th May 2005 01:38 PM
why relative hint path but absolute reference path gerry Microsoft Dot NET Framework 1 23rd Sep 2004 09:44 AM
relative path connection string for ado.net Martin Williams Microsoft VB .NET 1 17th Dec 2003 07:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:23 AM.