DBowers Posted February 25, 2008 Share Posted February 25, 2008 Hi, I am using the following code block to log into a database from AutoScript: $userName = InputBox("Login prompt", "Please enter your username.", "", "", 400, 50) $password = InputBox("Login prompt", "Please enter your password.", "", "*", 400, 50) $v_sqlConn = ObjCreate("ADODB.Connection") $v_sqlRecordSet = ObjCreate("ADODB.Recordset") $v_sqlConnStr = "Provider=SQLOLEDB;Data Source=myDSr;Initial Catalog=default;User ID=DBowers;Password=BowersD;" $v_sqlConn.Open($v_sqlConnStr) $v_sqlQuery = "SELECT * FROM TBL" $v_sqlRecordSet.Open($v_sqlQuery, $v_sqlConn) How would I know whether the username/password is right, and prompt for username/passwords again until they work? Thanks! Link to comment Share on other sites More sharing options...
Bert Posted February 25, 2008 Share Posted February 25, 2008 If the logon is incorrect, do you get a error on the return? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
DBowers Posted February 26, 2008 Author Share Posted February 26, 2008 If the logon is incorrect, do you get a error on the return? Hi, Thanks for the quick reply. On invalid login, I got the following error: Line 130 (File "C:\test.au3"): $v_sqlConn.Open($v_sqlConnStr) $v_sqlConn.Open($v_sqlConnStr)^ERROR Error: The requested action with this object has failed. I have tried using the following block to catch the error right after $v_sqlConn.Open() but that didn't work. If @error Then MsgBox(0x40000, 'Object', 'Failed') EndIf Any suggestions? Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now