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

Relative path to Access db

P: n/a
dw
Hello, all. I have a site that I'm testing on my LOCALHOST and also on a
remote server, depending on whether I'm at work or at home. I don't want the
OLEDBDATAAdapter to be pointing to the remote Access db, but to the local
one. The OLEDBDATAAdapter wizard puts the entire path of the db
(\\myserver\.... or c:\myprojects\....).

The db resides within the site's folders; is there anyway to use relative
paths for it (something like "global/data/project1.mdb")? Thanks :)
Nov 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Store the relative path in your web.config and do a Server.MapPath to get
the full path to the file...

Karl

"dw" <co***************@uncw.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello, all. I have a site that I'm testing on my LOCALHOST and also on a
remote server, depending on whether I'm at work or at home. I don't want the OLEDBDATAAdapter to be pointing to the remote Access db, but to the local
one. The OLEDBDATAAdapter wizard puts the entire path of the db
(\\myserver\.... or c:\myprojects\....).

The db resides within the site's folders; is there anyway to use relative
paths for it (something like "global/data/project1.mdb")? Thanks :)

Nov 18 '05 #2

P: n/a
dw
Thanks, Karl. What would I modify in my web.config file? Thanks.

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:uj**************@tk2msftngp13.phx.gbl...
Store the relative path in your web.config and do a Server.MapPath to get
the full path to the file...

Karl

"dw" <co***************@uncw.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello, all. I have a site that I'm testing on my LOCALHOST and also on a
remote server, depending on whether I'm at work or at home. I don't want

the
OLEDBDATAAdapter to be pointing to the remote Access db, but to the local one. The OLEDBDATAAdapter wizard puts the entire path of the db
(\\myserver\.... or c:\myprojects\....).

The db resides within the site's folders; is there anyway to use relative paths for it (something like "global/data/project1.mdb")? Thanks :)


Nov 18 '05 #3

P: n/a
Dim cn As OleDb.OleDbConnection

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath(ConfigurationSettings.AppSettings(" path"))) ' -->>>
c:\inetpub\wwwroot\global\data\project1.mdb

web.config...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="path" value="/global/data/project1.mdb" />
</appSettings>

<system.web>
.... etc

HTH,
Greg

"dw" <co***************@uncw.edu> wrote in message
news:er**************@TK2MSFTNGP09.phx.gbl...
Thanks, Karl. What would I modify in my web.config file? Thanks.

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:uj**************@tk2msftngp13.phx.gbl...
Store the relative path in your web.config and do a Server.MapPath to get
the full path to the file...

Karl

"dw" <co***************@uncw.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello, all. I have a site that I'm testing on my LOCALHOST and also on a remote server, depending on whether I'm at work or at home. I don't
want the
OLEDBDATAAdapter to be pointing to the remote Access db, but to the

local one. The OLEDBDATAAdapter wizard puts the entire path of the db
(\\myserver\.... or c:\myprojects\....).

The db resides within the site's folders; is there anyway to use relative paths for it (something like "global/data/project1.mdb")? Thanks :)



Nov 18 '05 #4

P: n/a
dw
Wow! Didn't know you could do that. Exactly what I was looking for. Thanks,
Greg :)

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:OA**************@TK2MSFTNGP11.phx.gbl...
Dim cn As OleDb.OleDbConnection

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath(ConfigurationSettings.AppSettings(" path"))) ' -->>>
c:\inetpub\wwwroot\global\data\project1.mdb

web.config...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="path" value="/global/data/project1.mdb" />
</appSettings>

<system.web>
... etc

HTH,
Greg

"dw" <co***************@uncw.edu> wrote in message
news:er**************@TK2MSFTNGP09.phx.gbl...
Thanks, Karl. What would I modify in my web.config file? Thanks.

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:uj**************@tk2msftngp13.phx.gbl...
Store the relative path in your web.config and do a Server.MapPath to
get the full path to the file...

Karl

"dw" <co***************@uncw.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> Hello, all. I have a site that I'm testing on my LOCALHOST and also
on a > remote server, depending on whether I'm at work or at home. I don't want the
> OLEDBDATAAdapter to be pointing to the remote Access db, but to the

local
> one. The OLEDBDATAAdapter wizard puts the entire path of the db
> (\\myserver\.... or c:\myprojects\....).
>
> The db resides within the site's folders; is there anyway to use

relative
> paths for it (something like "global/data/project1.mdb")? Thanks :)
>
>



Nov 18 '05 #5

P: n/a
Another useful tip is to use comments in your web.config so you can just
uncomment your other "path" when you switch locations, lot less typing...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!--
<add key="path" value="/global/data/project1.mdb" />
-->
<add key="path" value="/global/data/project2.mdb" />

</appSettings>

<system.web>

Greg

"dw" <co***************@uncw.edu> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
Wow! Didn't know you could do that. Exactly what I was looking for. Thanks, Greg :)

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:OA**************@TK2MSFTNGP11.phx.gbl...
Dim cn As OleDb.OleDbConnection

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath(ConfigurationSettings.AppSettings(" path"))) ' -->>>
c:\inetpub\wwwroot\global\data\project1.mdb

web.config...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="path" value="/global/data/project1.mdb" />
</appSettings>

<system.web>
... etc

HTH,
Greg

"dw" <co***************@uncw.edu> wrote in message
news:er**************@TK2MSFTNGP09.phx.gbl...
Thanks, Karl. What would I modify in my web.config file? Thanks.

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:uj**************@tk2msftngp13.phx.gbl...
> Store the relative path in your web.config and do a Server.MapPath to get
> the full path to the file...
>
> Karl
>
> "dw" <co***************@uncw.edu> wrote in message
> news:%2****************@tk2msftngp13.phx.gbl...
> > Hello, all. I have a site that I'm testing on my LOCALHOST and
also
on
a
> > remote server, depending on whether I'm at work or at home. I

don't want
> the
> > OLEDBDATAAdapter to be pointing to the remote Access db, but to

the local
> > one. The OLEDBDATAAdapter wizard puts the entire path of the db
> > (\\myserver\.... or c:\myprojects\....).
> >
> > The db resides within the site's folders; is there anyway to use
relative
> > paths for it (something like "global/data/project1.mdb")? Thanks :) > >
> >
>
>



Nov 18 '05 #6

P: n/a
Greg...an even better idea is to use a user.config file on one of the
machines to overwrite the default setting in the web.config

web.config -->
<appSettings file="user.config">
<a key="path" value="blah" />
</appSettings>

user.config -->
<appSettings>
<a key="path" value="otherblah" />
</appSettings>

if the user config is present, it'll return otherblah as the value..Great
for team development.

Karl

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Of**************@tk2msftngp13.phx.gbl...
Another useful tip is to use comments in your web.config so you can just
uncomment your other "path" when you switch locations, lot less typing...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!--
<add key="path" value="/global/data/project1.mdb" />
-->
<add key="path" value="/global/data/project2.mdb" />

</appSettings>

<system.web>

Greg

"dw" <co***************@uncw.edu> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
Wow! Didn't know you could do that. Exactly what I was looking for. Thanks,
Greg :)

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:OA**************@TK2MSFTNGP11.phx.gbl...
Dim cn As OleDb.OleDbConnection

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & Server.MapPath(ConfigurationSettings.AppSettings(" path"))) ' -->>>
c:\inetpub\wwwroot\global\data\project1.mdb

web.config...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="path" value="/global/data/project1.mdb" />
</appSettings>

<system.web>
... etc

HTH,
Greg

"dw" <co***************@uncw.edu> wrote in message
news:er**************@TK2MSFTNGP09.phx.gbl...
> Thanks, Karl. What would I modify in my web.config file? Thanks.
>
> "Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote
in
> message news:uj**************@tk2msftngp13.phx.gbl...
> > Store the relative path in your web.config and do a Server.MapPath

to get
> > the full path to the file...
> >
> > Karl
> >
> > "dw" <co***************@uncw.edu> wrote in message
> > news:%2****************@tk2msftngp13.phx.gbl...
> > > Hello, all. I have a site that I'm testing on my LOCALHOST and also
on
a
> > > remote server, depending on whether I'm at work or at home. I

don't want
> > the
> > > OLEDBDATAAdapter to be pointing to the remote Access db, but to the > local
> > > one. The OLEDBDATAAdapter wizard puts the entire path of the db
> > > (\\myserver\.... or c:\myprojects\....).
> > >
> > > The db resides within the site's folders; is there anyway to use
> relative
> > > paths for it (something like "global/data/project1.mdb")? Thanks :) > > >
> > >
> >
> >
>
>



Nov 18 '05 #7

P: n/a
Awesome! Not sure how I overlooked that all this time.

Greg

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:uH*************@TK2MSFTNGP09.phx.gbl...
Greg...an even better idea is to use a user.config file on one of the
machines to overwrite the default setting in the web.config

web.config -->
<appSettings file="user.config">
<a key="path" value="blah" />
</appSettings>

user.config -->
<appSettings>
<a key="path" value="otherblah" />
</appSettings>

if the user config is present, it'll return otherblah as the value..Great
for team development.

Karl

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Of**************@tk2msftngp13.phx.gbl...
Another useful tip is to use comments in your web.config so you can just
uncomment your other "path" when you switch locations, lot less typing...

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!--
<add key="path" value="/global/data/project1.mdb" />
-->
<add key="path" value="/global/data/project2.mdb" />

</appSettings>

<system.web>

Greg

"dw" <co***************@uncw.edu> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
Wow! Didn't know you could do that. Exactly what I was looking for.

Thanks,
Greg :)

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:OA**************@TK2MSFTNGP11.phx.gbl...
> Dim cn As OleDb.OleDbConnection
>
> cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
&
> Server.MapPath(ConfigurationSettings.AppSettings(" path"))) ' -->>>
> c:\inetpub\wwwroot\global\data\project1.mdb
>
> web.config...
>
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
> <appSettings>
> <add key="path" value="/global/data/project1.mdb" />
> </appSettings>
>
> <system.web>
> ... etc
>
> HTH,
> Greg
>
> "dw" <co***************@uncw.edu> wrote in message
> news:er**************@TK2MSFTNGP09.phx.gbl...
> > Thanks, Karl. What would I modify in my web.config file? Thanks.
> >
> > "Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>

wrote in
> > message news:uj**************@tk2msftngp13.phx.gbl...
> > > Store the relative path in your web.config and do a Server.MapPath to
> get
> > > the full path to the file...
> > >
> > > Karl
> > >
> > > "dw" <co***************@uncw.edu> wrote in message
> > > news:%2****************@tk2msftngp13.phx.gbl...
> > > > Hello, all. I have a site that I'm testing on my LOCALHOST and

also
on
> a
> > > > remote server, depending on whether I'm at work or at home. I

don't
> want
> > > the
> > > > OLEDBDATAAdapter to be pointing to the remote Access db, but
to the
> > local
> > > > one. The OLEDBDATAAdapter wizard puts the entire path of the
db > > > > (\\myserver\.... or c:\myprojects\....).
> > > >
> > > > The db resides within the site's folders; is there anyway to use > > relative
> > > > paths for it (something like "global/data/project1.mdb")?

Thanks :)
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 18 '05 #8

P: n/a
I'm resurrecting this thread because I need some clarification on settings.
So I too have made the db connection using th ui(designer) I check the
properties of the oledbconnection and can see the connection string. I can
also choose <dynamic properties> and add a key to the web.config with the
connection string (e.g. <add "dbConnect" value"string" />)

Now what I want to know is how do i use that config in place of the designer
generated string and how can I modify it to use a relative path (i.e.
server.mappath)

cheers
"Greg Burns" wrote:
Awesome! Not sure how I overlooked that all this time.

Greg

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:uH*************@TK2MSFTNGP09.phx.gbl...
Greg...an even better idea is to use a user.config file on one of the
machines to overwrite the default setting in the web.config

web.config -->
<appSettings file="user.config">
<a key="path" value="blah" />
</appSettings>

user.config -->
<appSettings>
<a key="path" value="otherblah" />
</appSettings>

if the user config is present, it'll return otherblah as the value..Great
for team development.

Karl

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Of**************@tk2msftngp13.phx.gbl...
Another useful tip is to use comments in your web.config so you can just
uncomment your other "path" when you switch locations, lot less typing...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!--
<add key="path" value="/global/data/project1.mdb" />
-->
<add key="path" value="/global/data/project2.mdb" />

</appSettings>

<system.web>

Greg

"dw" <co***************@uncw.edu> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
> Wow! Didn't know you could do that. Exactly what I was looking for.
Thanks,
> Greg :)
>
> "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
> news:OA**************@TK2MSFTNGP11.phx.gbl...
> > Dim cn As OleDb.OleDbConnection
> >
> > cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data

Source="
&
> > Server.MapPath(ConfigurationSettings.AppSettings(" path"))) ' -->>>
> > c:\inetpub\wwwroot\global\data\project1.mdb
> >
> > web.config...
> >
> > <?xml version="1.0" encoding="utf-8" ?>
> > <configuration>
> > <appSettings>
> > <add key="path" value="/global/data/project1.mdb" />
> > </appSettings>
> >
> > <system.web>
> > ... etc
> >
> > HTH,
> > Greg
> >
> > "dw" <co***************@uncw.edu> wrote in message
> > news:er**************@TK2MSFTNGP09.phx.gbl...
> > > Thanks, Karl. What would I modify in my web.config file? Thanks.
> > >
> > > "Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>

wrote
> in
> > > message news:uj**************@tk2msftngp13.phx.gbl...
> > > > Store the relative path in your web.config and do a Server.MapPath to
> > get
> > > > the full path to the file...
> > > >
> > > > Karl
> > > >
> > > > "dw" <co***************@uncw.edu> wrote in message
> > > > news:%2****************@tk2msftngp13.phx.gbl...
> > > > > Hello, all. I have a site that I'm testing on my LOCALHOST and
also
> on
> > a
> > > > > remote server, depending on whether I'm at work or at home. I
don't
> > want
> > > > the
> > > > > OLEDBDATAAdapter to be pointing to the remote Access db, but to the
> > > local
> > > > > one. The OLEDBDATAAdapter wizard puts the entire path of the db > > > > > (\\myserver\.... or c:\myprojects\....).
> > > > >
> > > > > The db resides within the site's folders; is there anyway to use > > > relative
> > > > > paths for it (something like "global/data/project1.mdb")? Thanks :)
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.