Jump to content
Sign in to follow this  
GAM

Variable must be of type "Object"

Recommended Posts

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

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

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  

×
×
  • Create New...