[thelist] trying two passwords in ASP vbscript

David Turner david.turner at synergy.tv
Thu Aug 21 08:44:55 CDT 2003


not really...

the problem is that my isp is going to change the SQL password for 1 site,
but i dont know exactly when, and i dont want any down time.

so i want the code to try the old SQL password, and if that fails, it should
try the new SQL password.

my code before was actually wrong, i have modified it to.

-------

Sub DBConnect

  On Error Resume Next
  Set Database_Connection = Server.CreateObject("ADODB.Connection")

  ' first try old password
  '
  Database_Connection.Open
"Driver={SQLServer};Server=sql.mywebsite.com;Database=db;UID=db;PWD=old_pass
word"

  ' if we get an error then try the new password
  '
  if Database_Connection.Errors.Count > 0 then
    Database_Connection.Errors.Clear
    Database_Connection.Open
"Driver={SQLServer};Server=sql.mywebsite.com;Database=db;UID=db;PWD=new_pass
word"
  End if

End Sub

-------

thanks






david.

-----Original Message-----
From: thelist-bounces at lists.evolt.org

use a global variable set in an include file where you establish all
your constants... then when you upload it, just uncomment the code
that sets your uid/pwd to the production db and comment out the code
that sets it to the test db...

if you don't want to have to change it, use the values from the
server variables request object to determine which to use based on
the name of the serverdomain name...

that help?

--



More information about the thelist mailing list