[thelist] trying two passwords in ASP vbscript

Tab Alleman Tab.Alleman at MetroGuide.com
Thu Aug 21 08:41:10 CDT 2003


David Turner wrote:
> Sub DBConnect
> 
>   On Error Resume Next
>     Set Database_Connection = Server.CreateObject("ADODB.Connection")
> 
>     ' try old password
>     '
>     Database_Connection.Open "Driver={SQL
> Server};Server=sql.mywebsite.com;Database=db;UID=db;PWD=old_password"
> 
>     ' and then the new password
>     '
>     Database_Connection.Open "Driver={SQL
> Server};Server=sql.mywebsite.com;Database=db;UID=db;PWD=new_password"
> 
> End Sub

Have you tested it yet?  It seems like this code wouldn't work until
your password changed, because you'd open a good connection with your
old password, and then you'd overwrite that connection (because you're
using the same variable name for the connection object) with a
connection that won't work (new password).  

You might need to:

Open connection with old password
IF Err.Number <> 0 THEN
	Open connection with new password
END IF


More information about the thelist mailing list