GAM Posted September 15, 2014 Share Posted September 15, 2014 (edited) Hi All Am trying to write a script that retreives the values form the database but it gives me an error "Variable must be of type "Object". Can someone help me please. The code is as follows... ---------------------------------------------------------------------------------- $constrim="DRIVER={SQL Server};SERVER=WIN-1VETHTGJK1NEPOSERVER;DATABASE=AntiVirus;uid=Administrator;pwd=Welcome2mcafee;" $adCN = ObjCreate ("ADODB.Connection") ; <== Create SQL connection $adCN.Open ($constrim) ; <== Connect with required credentials MsgBox(0,"",$constrim ) if @error Then MsgBox(0, "ERROR", "Failed to connect to the database") Exit Else MsgBox(0, "Success!", "Connection to database successful!") EndIf $sQuery = ObjGet("select * from Sample1 where USerID = 'ABC'") $result = $adCN.Execute($sQuery) MsgBox(0, "", $result.Fields( "UserID" ).Value) $adCN.Close Edited September 15, 2014 by GAM Neil Link to comment Share on other sites More sharing options...
GAM Posted September 15, 2014 Author Share Posted September 15, 2014 The complete error that gives is... "C:Program Files (x86)AutoIt3SciTE..autoit3.exe" /ErrorStdOut "C:UsersAdministratorDesktopppmstemp.au3" "C:UsersAdministratorDesktopppmstemp.au3" (18) : ==> Variable must be of type "Object".: MsgBox(0, "", $result.Fields( "UserID" ).Value) MsgBox(0, "", $result^ ERROR Neil Link to comment Share on other sites More sharing options...
Luigi Posted September 15, 2014 Share Posted September 15, 2014 Hi GAM, the driver ODBC is installed? For me, if I don't install ODBC to Postgress or MySQL, I receive the same error message. I never use MSSQL (I presumed). Or your ODBC is not properly config. Visit my repository 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