Print Page | Close Window

trying to set DSN dynamically

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=18421
Printed Date: 29 March 2026 at 1:22pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: trying to set DSN dynamically
Posted By: bubberz
Subject: trying to set DSN dynamically
Date Posted: 17 February 2006 at 8:05pm
I'm trying the following code, but get an HTTP 500

Here's my .asp code for the DSN:
<!-- Below file, VBFunctions.inc, will do select case for deciding on proper DSN based upon session("sessionDB") or ""-->
<!--#include file="VBFunctions.inc" -->
<%
If session("sessionDB") <> "" Then
'means user is using web app, and need to pass function, FunctDBSelect(), the session object

test = FunctDBSelect(session("sessionDB"))
varDSN = FunctionDBSelect
else
varDSN = "sns_prod"

Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open varDSN
'also tried MyConn.Open "varDSN", but with no luck

*******************
*******************

Here's the function in the VBFunctions.inc file:
<%Function FunctDBSelect(useDB)
select case useDB
case "ADSFO"
FunctDBSelect = "ADSFO_prod"
case "AFSS"
FunctDBSelect = "AFSS_prod"
case "CHS"
FunctDBSelect = "CHS_prod"
case "Demo"
FunctDBSelect = "Demo_prod"
case "EP"
FunctDBSelect = "EP_prod"
case "NSS"
FunctDBSelect = "NSS_prod"
case "OE"
FunctDBSelect = "OE_prod"
case "PMP"
FunctDBSelect = "PMP_prod"
case "RN"
FunctDBSelect = "RN_prod"
case "SP"
FunctDBSelect = "SP_prod"
case "SS"
FunctDBSelect = "SS_prod"
case "WI"
FunctDBSelect = "WI_prod"
case "WSO"
FunctDBSelect = "WSO_prod"
return FunctDBSelect
end select
End Function%>



Replies:
Posted By: dpyers
Date Posted: 17 February 2006 at 10:03pm
turn off friendly http error messages in your browser options to show the real error instead of the generic 500 error.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: bubberz
Date Posted: 18 February 2006 at 3:31am
dpyers,
 
Thanks for the reply.
 
I'm going to try this, which should solve the issue:
 
if session("sessionDB") <> "" then
varDSN = FunctDBSelect(session("sessionDB"))
else
.....
 
Instead of the original which doesn't work of:
 
if session("sessionDB") <> "" then
test = FunctDBSelect(session("sessionDB"))
varDSN = FunctDBSelect(FunctDBSelect)
else



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net