Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - trying to set DSN dynamically
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

trying to set DSN dynamically

 Post Reply Post Reply
Author
bubberz View Drop Down
Newbie
Newbie


Joined: 17 February 2006
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote bubberz Quote  Post ReplyReply Direct Link To This Post Topic: trying to set DSN dynamically
    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%>
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
bubberz View Drop Down
Newbie
Newbie


Joined: 17 February 2006
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote bubberz Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.