By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,740 Members | 844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,740 IT Pros & Developers. It's quick & easy.

relative path in web.config

P: n/a
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
source=c:/Inetpub/MyApp/data/database.mdb" />
...

I would rather use

<add key="conAccess" value="microsoft.jet.oledb.4.0;data
source=data/database.mdb" />

however this doesn't work: I get an error like
"C:\WINNT\system32\data\database.mdb is not a valid path. ..."
can anyone help?

cheers, Jan Vandorpe
Nov 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You unlikely have the notion of current path (preventing to have a relative
path) in this context.

I would store this info separately and would have the code translating the
relative path to an absolute path. For example you could store :

~/../../data/MyBase.mdb and use Server.MapPath to inject the absolute path
in the connection string, the path in the web.config file being relative to
the root of the web site...

Patrice
--

"openleren" <op*******@skynet.be> a écrit dans le message de
news:41***********************@news.skynet.be...
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
source=c:/Inetpub/MyApp/data/database.mdb" />
...

I would rather use

<add key="conAccess" value="microsoft.jet.oledb.4.0;data
source=data/database.mdb" />

however this doesn't work: I get an error like
"C:\WINNT\system32\data\database.mdb is not a valid path. ..."
can anyone help?

cheers, Jan Vandorpe

Nov 18 '05 #2

P: n/a
Hi,

I am not following you:

Firstly I have tried ~/data/MyBase.mdb and it doesn't work because the
server transplants it for some reason on my system32 directory.
Secondly how can I use Server.mapPath in an xml file?

sorry...

Jan

"Patrice" <no****@nowhere.com> wrote in message
news:OB**************@TK2MSFTNGP09.phx.gbl...
You unlikely have the notion of current path (preventing to have a relative path) in this context.

I would store this info separately and would have the code translating the
relative path to an absolute path. For example you could store :

~/../../data/MyBase.mdb and use Server.MapPath to inject the absolute path
in the connection string, the path in the web.config file being relative to the root of the web site...

Patrice
--

"openleren" <op*******@skynet.be> a écrit dans le message de
news:41***********************@news.skynet.be...
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
source=c:/Inetpub/MyApp/data/database.mdb" />
...

I would rather use

<add key="conAccess" value="microsoft.jet.oledb.4.0;data
source=data/database.mdb" />

however this doesn't work: I get an error like
"C:\WINNT\system32\data\database.mdb is not a valid path. ..."
can anyone help?

cheers, Jan Vandorpe


Nov 18 '05 #3

P: n/a
I'll try to rephrase that.

IMO it's best to avoid non controlled relative path in a connection string
(what is the current path for an OLEDB provider ?).

Instead of storing the whole connection string in a single entry in the web
config file, I would store the Data Source entry as a separate entry in the
web config file. When the app retrieve this entry it can then use
server.mappath (or whatever else) to translate this relative path to an
absolute path. This absolute path can then be used to construct the final
connection string.

As a side note and as for now the path is taken relative to
c:\windows\system32, the other option would be to create your relative path
to your file from the c:\windows\system32 directory. That said and should
this base directory change for some reason, it would messed up the file
path.

Patrice

--

"openleren" <op*******@skynet.be> a écrit dans le message de
news:41***********************@news.skynet.be...
Hi,

I am not following you:

Firstly I have tried ~/data/MyBase.mdb and it doesn't work because the
server transplants it for some reason on my system32 directory.
Secondly how can I use Server.mapPath in an xml file?

sorry...

Jan

"Patrice" <no****@nowhere.com> wrote in message
news:OB**************@TK2MSFTNGP09.phx.gbl...
You unlikely have the notion of current path (preventing to have a

relative
path) in this context.

I would store this info separately and would have the code translating the
relative path to an absolute path. For example you could store :

~/../../data/MyBase.mdb and use Server.MapPath to inject the absolute path in the connection string, the path in the web.config file being relative

to
the root of the web site...

Patrice
--

"openleren" <op*******@skynet.be> a écrit dans le message de
news:41***********************@news.skynet.be...
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
source=c:/Inetpub/MyApp/data/database.mdb" />
...

I would rather use

<add key="conAccess" value="microsoft.jet.oledb.4.0;data
source=data/database.mdb" />

however this doesn't work: I get an error like
"C:\WINNT\system32\data\database.mdb is not a valid path. ..."
can anyone help?

cheers, Jan Vandorpe



Nov 18 '05 #4

P: n/a

hi all,

good forum this! :)

my problem is, basically:
microsoft access
page forms
page connection is unable to connect once i hosted it in my web
i already tried to change the path, both to absolute and relative path
but once i saved itm, it always returns to C:

example:relative
i changed it to /data_files/database.mdb
when i open it again it has changed to C:/data_files/database.mdb

example: absolute
i change it to ftp://blablabla
then it changed to: C:\blablabla\ftp://blablabla

please help :(

thanks in advance :)

--
anfieldadorer
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Jan 23 '06 #5

P: n/a

anfieldadorer wrote:
*hi all,

good forum this! :)

my problem is, basically:
microsoft access
page forms
page connection is unable to connect once i hosted it in my web
i already tried to change the path, both to absolute and relative
path
but once i saved itm, it always returns to C:

example:relative
i changed it to /data_files/database.mdb
when i open it again it has changed to C:/data_files/database.mdb

example: absolute
i change it to ftp://blablabla
then it changed to: C:\blablabla\ftp://blablabla

please help :(

thanks in advance :) *


please :(

--
anfieldadorer
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Jan 24 '06 #6

P: n/a
WHAT are you talking about - we cannot read your mind :-)

--Daniel
http://staff.newtelligence.com/danielf/


-----Original Message-----
From: anfieldadorer [mailto:an******************@mail.codecomments.com]
Posted At: Tuesday, January 24, 2006 12:14 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: relative path in web.config
Subject: Re: relative path in web.config
anfieldadorer wrote:
*hi all,

good forum this! :)

my problem is, basically:
microsoft access
page forms
page connection is unable to connect once i hosted it in my web
i already tried to change the path, both to absolute and relative
path
but once i saved itm, it always returns to C:

example:relative
i changed it to /data_files/database.mdb
when i open it again it has changed to C:/data_files/database.mdb

example: absolute
i change it to ftp://blablabla
then it changed to: C:\blablabla\ftp://blablabla

please help :(

thanks in advance :) *


please :(

--
anfieldadorer
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
Jan 24 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.