When I declared the connection string inside of global.asa, my
application's FORMS can access it fine, but it is out of scope from
the VB class modules. For example, when I declare this in the
global.asa:
Application("ConnectionString") =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Application("PhysPath") & "\test.mdb;"
then the code
Dim conOleDb As New OleDb.OleDbConnection()
conOleDb.ConnectionString = Application("ConnectionString")
works great inside a form's code behind, but the Application object is
not accessible from a class module.
Where and how is the best place to declare a connection string to an
Access database which is accessible to both forms and classes, and
whose location is not hard-coded (i.e. use Server.MapPath(".") to
identify the database's location)?
Thanks.
On Thu, 6 Nov 2003 09:55:50 -0500, "Kevin Spencer"
<ke***@DIESPAMMERSDIEtakempis.com> wrote:
How can I use the Server.MapPath(".") value inside of the web.config?
You can't. You can only store static data in the web.config file.
You might want to use the global.asa Application_OnStart method and create
the variable as an Application Cache value instead.