Ipsum Posted July 16, 2009 Share Posted July 16, 2009 Hi, I'm writing a small app that shows a check box list of databases a user can access. The user will then check those boxes, and perform a fixed set of actions on the databases he/she selects. After looking around here on how to use AutoIt with MSSQL, here is what I came up with: $g_userName = InputBox("Login", "Please enter your username.", @UserName, "", 400, 50) $g_password = InputBox("Login", "Please enter your password.", "", "*", 400, 50) ; Accesses database $g_sqlConn = ObjCreate("ADODB.Connection") $g_sqlRecordSet = ObjCreate("ADODB.Recordset") $g_sqlConnStr = "Provider=SQLOLEDB;Data Source=" & $c_DATABASE_SERVER & ";Initial Catalog=DB1;User ID=" & $g_userName & ";Password=" & $g_password & ";" $g_sqlConn.Open($g_sqlConnStr) And I call Open() for each database. If it does not fail, I show the check box for that database. If I get an error, I know the user can't access that database. Instead of relying on errors and exceptions, is there a better way to tell whether a user has access? Many thanks! Link to comment Share on other sites More sharing options...
ReFran Posted July 16, 2009 Share Posted July 16, 2009 Instead of relying on errors and exceptions, is there a better way to tell whether a user has access?Somthing like this:$oDb.Open($DsnName) If IsObj($oDb) = 0 ThenMsgBox(0,"","Not connected")Exitbr, Reinhard Link to comment Share on other sites More sharing options...
Ipsum Posted July 16, 2009 Author Share Posted July 16, 2009 Thanks! That solved the problem. 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