How do I check to see if Oracle SID Exists?

C

Colin Steadman

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
 
R

Ray at

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
 
C

Colin Steadman

Ray at said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top