473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

path to file

I know how to connect to a database using a full path. Something like
C:\path to application\bin\database.mdb

How do I create a relative path so that my application is portable?

Thanks
Laura K
Nov 20 '05 #1
8 952
Hi Laura,

Assuming this is Access or something like that, than you can set the
connectionstring of the connection in the load event of your form. (Do not
delete the old one in the designer let everything there, only set it again
in the load event).

something as
conn.connectionstring = "xxxxxxx

I hope this helps?

Cor
I know how to connect to a database using a full path. Something like
C:\path to application\bin\database.mdb

How do I create a relative path so that my application is portable?

Thanks
Laura K

Nov 20 '05 #2
\Bin\database.mdb should do I guess

"Laura K" <kl*******@ATcharter.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
I know how to connect to a database using a full path. Something like
C:\path to application\bin\database.mdb

How do I create a relative path so that my application is portable?

Thanks
Laura K

Nov 20 '05 #3
* "Laura K" <kl*******@ATcharter.net> scripsit:
I know how to connect to a database using a full path. Something like
C:\path to application\bin\database.mdb

How do I create a relative path so that my application is portable?


<URL:http://www.google.de/groups?selm=OUnKclfSEHA.3476%40tk2msftngp13.phx.gb l>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
didn't work.

It works with the full path but not with a relative path.

Any other suggestions?

Laura
"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
\Bin\database.mdb should do I guess

"Laura K" <kl*******@ATcharter.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
I know how to connect to a database using a full path. Something like
C:\path to application\bin\database.mdb

How do I create a relative path so that my application is portable?

Thanks
Laura K


Nov 20 '05 #5
Just use the database name rather than a full path or you should be able to
use stuff like

...\directory or .\directory.

You could get the best of both worlds and use the app.config. or an xml
file, or the registry to store the absolute values, and allow the program to
check to see if a key exists and if not simply set the connection string up
to the current directory

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
"Laura K" <kl*******@ATcharter.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
I know how to connect to a database using a full path. Something like
C:\path to application\bin\database.mdb

How do I create a relative path so that my application is portable?

Thanks
Laura K

Nov 20 '05 #6
Use application.startuppath to get your working directory, store that in a
variable, and append that to your file names.

"Laura K" <kl*******@ATcharter.net> wrote in message
news:OI*************@TK2MSFTNGP10.phx.gbl...
didn't work.

It works with the full path but not with a relative path.

Any other suggestions?

Laura
"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
\Bin\database.mdb should do I guess

"Laura K" <kl*******@ATcharter.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
I know how to connect to a database using a full path. Something like
C:\path to application\bin\database.mdb

How do I create a relative path so that my application is portable?

Thanks
Laura K



Nov 20 '05 #7
* "Sameh Ahmed" <es******@hotmail.com> scripsit:
\Bin\database.mdb should do I guess


I assume you wanted to type ".\databases\sample.mdb".

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #8
OK got it.

Apparently for a relative path one should omit the bin file as part of the
path.

I also tried the application.startuppath

Both ways worked find.

Thanks

Laura K
"Laura K" <kl*******@ATcharter.net> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
I know how to connect to a database using a full path. Something like
C:\path to application\bin\database.mdb

How do I create a relative path so that my application is portable?

Thanks
Laura K

Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff...
70
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
2
by: Rob Cowie | last post by:
Hi, Given a string representing the path to a file, what is the best way to get at the filename? Does the OS module provide a function to parse the path? or is it acceptable to split the string...
6
by: openleren | last post by:
Hi all, how can I use a relative path in my web.config file for an Access db?: Instead of using <configuration> <appSettings> <add key="conAccess" value="microsoft.jet.oledb.4.0;data...
2
by: Tom Wells | last post by:
I have a little file upload page that I have been able to use to successfully upload files to the C: drive of LocalHost (my machine). I need to be able to upload to a network drive from the intranet...
6
by: I am Sam | last post by:
I keep getting this error and I don't know why: The path is too long after being fully qualified. Make sure path is less than 260 characters. Description: An unhandled exception occurred...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
5
by: 7stud | last post by:
Here's the code: ------------ import os, os.path, pprint mydir = "/Users/me/2testing" files = pprint.pprint(files) print os.path.join(mydir, "helloWorld.py")
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.