1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

trying to set DSN dynamically

Discussion in 'C#' started by bubberz, Feb 17, 2006.

  1. #1
    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"
    SEMrush
    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%>
     
    bubberz, Feb 17, 2006 IP
    SEMrush
  2. bubberz

    bubberz Guest

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It should have been:

    if session("sessionDB") <> "" then
    test = FunctDBSelect(session("sessionDB"))
    varDSN = FunctionDBSelect
    else
    varDSN = "sns_prod"
    end if
     
    bubberz, Feb 17, 2006 IP
  3. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Without more descriptive error messages and complete code samples, it'll be hard to diagnose. Here's a place to start - lets get rid of the generic error message and see what's really happening.

    Error 500 is a generic error message your browser gives you. to disable this and force your browser to show you the real error message, do this:

    go to tools menu in IE

    Choose "internet options"

    Choose the "advanced" tab

    uncheck the checkbox next to "Show Friendly HTTP Error Messages"

    for graphical walkthrough - click here.

    once you have turned off friendly error messages, you should get a much more useful error message back from your browser. ASP will tell you exactly what's wrong with your code, and which line it's occurring on.

    If that doesn't help you weed out your issues, post back here with your specific error message and post a code snippet so that we can see what's going on on that particular line of your file.

    HTH

    EDIT:

    i did notice that on the line that reads

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

    shouldn't it read:

    test = FunctDBSelect(session("sessionDB"))
    varDSN = FunctDBSelect

    I don't see anywhere in your code where you define "FunctionDBSelect", though you are defining "FunctDBSelect" in your function.
     
    vectorgraphx, Feb 17, 2006 IP
  4. bubberz

    bubberz Guest

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Got it with:

    if session("sessionDB") <> "" then
    VarDSN = FunctDBSelect(session("sessionDB"))
    else
    varDSN = "sns_prod"
    end if
     
    bubberz, Feb 21, 2006 IP