Sign in to follow this  
Followers 0
GAM

Variable must be of type "Object"

3 posts in this topic

#1 ·  Posted (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 by GAM

Neil

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0