Asp.net global connection string to access database

C

Colin Graham

i am currently developing an asp.net web application which is linked
to an Access database.

The main problem that i have is in creating a global connection string
that i can use. When i put my string into either the appsettings or a
global settings module i get an error on the server.mappath part of
the string. how can i get round this as i dont want to have to use a
specific path for the web application. it seems that this should be
easy as i can use a relative path in other parts of the system.

I suppose i could set a session state value or application state value
on start up but i hope someone can shed some light on my issue.

thanks in advance

C
 
J

Jeff Sheldon

Colin,
Try this.
In your webconfig:
<appSettings>
<add key="DBPath" value="db/file.mdb" />
</appSettings>
And simply use this function:
Private Function GetConnectionString() As String
Dim strPath As String = System.Configuration.ConfigurationSettings.
AppSettings("DBPath")
Return Server.MapPath(strPath)
End Function

Or anything simular,
Hope this helps
-Jeff
4/4/2005 6:01:35 PM
 

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

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top