How can I reference an include page from global.asa?

D

Dave

I have different database connections that I use for DEV and PROD versions
of our web app.

I want to put the database connection string in one location so I only have
to change it once when we push live.

So I put it in an include file and reference it in all my asp pages as:
<!--#include file="includes/db_conn.inc"-->

But this will not work with the global.asa page.

How can I reference an include page from global.asa?
 
M

Mike Brind

Dave said:
I have different database connections that I use for DEV and PROD versions
of our web app.

I want to put the database connection string in one location so I only
have to change it once when we push live.

So I put it in an include file and reference it in all my asp pages as:
<!--#include file="includes/db_conn.inc"-->

But this will not work with the global.asa page.

How can I reference an include page from global.asa?


Don't store the connection string in an include. Store it in the global.asa
as an appplication variable:

Sub Application_OnStart
Application("connStr") = "Provider=<provider>;Data Source=<datasource>"
End Sub
 
D

Dave

Yes. That works much better.

Thanks



Mike Brind said:
Don't store the connection string in an include. Store it in the
global.asa as an appplication variable:

Sub Application_OnStart
Application("connStr") = "Provider=<provider>;Data Source=<datasource>"
End Sub
 
S

Steven Cheng[MSFT]

Hello Dave,

Another option is create a lightweight COM component and use it to return
connectionstring, this can help hidden the connectionstring in COM object
instead of put the clear text in global.asa or other page file. You can use
VB to create a activex component conveniently. And in your page or
global.asa you just need to create the COM object and query for
connectionstring. e.g.

=============

<%
dim obj
dim connstr

obj = Server.CreateObject("mycomponent")
connstr = obj.GetConnectionString()


%>

==========

Hope also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top