How do I check to see if Oracle SID Exists?

Discussion in 'ASP General' started by Colin Steadman, Dec 17, 2003.

  1. I have built a page that lists all our databases, the
    users connected to each database, and what application
    they are using. Because these databases are moved, or
    removed from time to time I need to check if the database
    still exists before trying to query it. Otherwise I get
    funny SID errors when it tries to process this command:-

    Conn4.Open "Provider=OraOLEDB.Oracle;" & _
    "Data Source=CD;" & _
    "User Id=username;" & _
    "Password=password"

    Can this be done in ASP or should I be querying the error
    collection or something?

    TIA,

    Colin
     
    Colin Steadman, Dec 17, 2003
    #1
    1. Advertising

  2. Colin Steadman

    Ray at Guest

    I've used code like this before:
    On Error Resume Next
    Conn4.Open "Provider=OraOLEDB.Oracle;" & _
    "Data Source=CD;" & _
    "User Id=username;" & _
    "Password=password"

    Select Case True
    Case Err.Number = 0
    ''logged in fine
    Case Instr(Err.Description, "does not exist") > 0
    Response.Write "That user doesn't exist."
    Case Instr(Err.Description, "some other error string") > 0
    Response.Write "Some other error that you'd like the user to see."
    End Select
    On Error Goto 0


    My actual code:

    Set objADO = Server.CreateObject("ADODB.Connection")
    objADO.Open TheConnectionStringVariableWithUIDandPwd

    Select Case True
    Case Err.Number = 0
    '''fine, continue
    blnContinue = True
    Case Instr(Err.Description, "does not exist") > 0
    Response.Write "User " & strUsername & " does not exist on our AS/400."
    Case Instr(Err.Description, "is not correct") > 0
    Response.Write "The password you entered for " & strUsername & " is not
    correct. Please go back and try again."
    Case Instr(Err.Description, "has been disabled") > 0
    Response.Write strUsername & " is disabled on the AS/400 and will need to
    be reset."
    Case Else
    Response.Write "An unknown error has occurred. Sorry about that."
    End Select


    Ray at work


    "Colin Steadman" <> wrote in message
    news:05ed01c3c4c0$155bf9a0$...
    > I have built a page that lists all our databases, the
    > users connected to each database, and what application
    > they are using. Because these databases are moved, or
    > removed from time to time I need to check if the database
    > still exists before trying to query it. Otherwise I get
    > funny SID errors when it tries to process this command:-
    >
    > Conn4.Open "Provider=OraOLEDB.Oracle;" & _
    > "Data Source=CD;" & _
    > "User Id=username;" & _
    > "Password=password"
    >
    > Can this be done in ASP or should I be querying the error
    > collection or something?
    >
    > TIA,
    >
    > Colin
     
    Ray at, Dec 17, 2003
    #2
    1. Advertising

  3. "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message news:<>...
    > I've used code like this before:
    > On Error Resume Next
    > Conn4.Open "Provider=OraOLEDB.Oracle;" & _
    > "Data Source=CD;" & _
    > "User Id=username;" & _
    > "Password=password"
    >
    > Select Case True
    > Case Err.Number = 0
    > ''logged in fine
    > Case Instr(Err.Description, "does not exist") > 0
    > Response.Write "That user doesn't exist."
    > Case Instr(Err.Description, "some other error string") > 0
    > Response.Write "Some other error that you'd like the user to see."
    > End Select
    > On Error Goto 0
    >
    >
    > My actual code:
    >
    > Set objADO = Server.CreateObject("ADODB.Connection")
    > objADO.Open TheConnectionStringVariableWithUIDandPwd
    >
    > Select Case True
    > Case Err.Number = 0
    > '''fine, continue
    > blnContinue = True
    > Case Instr(Err.Description, "does not exist") > 0
    > Response.Write "User " & strUsername & " does not exist on our AS/400."
    > Case Instr(Err.Description, "is not correct") > 0
    > Response.Write "The password you entered for " & strUsername & " is not
    > correct. Please go back and try again."
    > Case Instr(Err.Description, "has been disabled") > 0
    > Response.Write strUsername & " is disabled on the AS/400 and will need to
    > be reset."
    > Case Else
    > Response.Write "An unknown error has occurred. Sorry about that."
    > End Select
    >
    >
    > Ray at work



    Aha! That does the trick.

    Thanks for sharing.

    Colin
     
    Colin Steadman, Dec 18, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pgar
    Replies:
    1
    Views:
    4,989
    =?Utf-8?B?U2FudGhhbmEgR29wYWxhbg==?=
    Nov 15, 2004
  2. Sugapablo
    Replies:
    1
    Views:
    17,507
  3. Steve Kershaw
    Replies:
    1
    Views:
    392
    Brennan Stehling
    Sep 26, 2006
  4. Ulf Meinhardt
    Replies:
    8
    Views:
    6,302
  5. Feyruz
    Replies:
    4
    Views:
    2,337
    Sherm Pendley
    Oct 14, 2005
Loading...

Share This Page