Link to home
Start Free TrialLog in
Avatar of rivkamak
rivkamakFlag for United States of America

asked on

Catch unable to login to mssql connection

I have an if-then statement to catch if I am unable to make a live connection to  MSSQL database.
but I'm hitting an error now, that login is invalid.
Is there an if statement that will catch any of these too?
I only want my users to see the information once we are all connected.
Avatar of Daniel Reynolds
Daniel Reynolds
Flag of United States of America image

in your catch have you tried using the following error type?

catch (SQLException ex)
{

{
Avatar of rivkamak

ASKER

This is my current script in ASp.
Where would I add that?

set myConn = Server.CreateObject("ADODB.Connection")
myConn.open MM_donorSelect_app1
 if myConn.State = 1 then 
 response.write("First app is working")
stringUse = MM_donorSelect_app1
openConnection = true

end if

Open in new window

Since you are using vbscript, you would need to use OnError

I am not sure you get the same opportunity to catch the error in classic ASP like that.
Any other ideas?
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you explain what happens when the user hits the error like login failed?
Will they get a MSSQL error, or will they just a response.write?

Can I just remove the response.write section and put  a nice message like: You are unable to connect right now, please try again tommorow"
>>Can you explain what happens when the user hits the error like login failed?<<
Error message(s) will be displayed.  Note: There could be more than one error message.
>>Will they get a MSSQL error, or will they just a response.write?<<
Both.
>>Can I just remove the response.write section and put  a nice message like: You are unable to connect right now, please try again tommorow" <<
Of course.  I am merely gave you the code so that you could produce custom messages in each case.