connection string, how to?

C

CSharp

Hello all,

I store the connection string in my web.config like this:

<appSettings>
<add key="ConnectionString"
value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\inetput\wwwroot\testapp\DB\gb.mdb;" />
</appSettings>

Instead of hardcoding the path of the db file, I want to specify the
relative path. My db is in the DB subfolder of my application folder. How
can I do this?

Thanks
SeeSharp
 
T

Teemu Keiski

Give the relative path in separate key/value pair. At runtime, resolve the
location using Server.MapPath(relative_path) and concatenate the resulted
path with the original ConnectionString to construct the complete connection
string.
 
C

CSharp

Thanks

SeeSharp

Teemu Keiski said:
Give the relative path in separate key/value pair. At runtime, resolve the
location using Server.MapPath(relative_path) and concatenate the resulted
path with the original ConnectionString to construct the complete connection
string.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top