Currently I set the ADO connect string for my site into a 'constant' that is used by all the asp pages on my site. This allows me to change the database that I connect to depending on whether I am in test mode or production mode.
I now want to test for which server the code is running on and then in code set the 'constant' variable to the right connection string. I can easily determine which server is running the code, but if I use either an IF or SELECT to set the 'costant', I get an error message that I can't change a 'constant'. It's like it is ignoring the IF or SELECT and processing every 'const....' statement.
Here's a sample of the code that is causing the trouble:
The code is run only once for each session. The code is by itself in an 'include' file. The 'dbDataSource' variable is used on virturally every page of the web site. I don't want to recode all the pages as this site and other similar sites may have to be redone in 6-9 months anyway, but this small change would save time and eliminate risk to production data in the meantime. Thanks,
I now want to test for which server the code is running on and then in code set the 'constant' variable to the right connection string. I can easily determine which server is running the code, but if I use either an IF or SELECT to set the 'costant', I get an error message that I can't change a 'constant'. It's like it is ignoring the IF or SELECT and processing every 'const....' statement.
Here's a sample of the code that is causing the trouble:
Code:
<%
txtServerType = fnServerType
If txtServerType = "Dev" Then
' Use for development server
Const dbDataSource = "Provider=SQLOLEDB.1;Initial1 ..."
ElseIF txtServerType = "Stage" Then
' Use for Staging server
Const dbDataSource = "Provider=SQLOLEDB.1;Initial2 ..."
ElseIF txtServerType = "Prod" Then
' Use for production server
Const dbDataSource = "Provider=SQLOLEDB.1;Initial3 ..."
End IF
%>
The code is run only once for each session. The code is by itself in an 'include' file. The 'dbDataSource' variable is used on virturally every page of the web site. I don't want to recode all the pages as this site and other similar sites may have to be redone in 6-9 months anyway, but this small change would save time and eliminate risk to production data in the meantime. Thanks,