Jump to content

Recommended Posts

Posted

Here is the script that I have...

'Create an ADO connection object

Set adoCon = CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection

adoCon.Open "SIM"

Set rsSIM = CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database

strSQL = "SELECT count (*) as Total from devices where overallstatus='0';"

'Open the recordset with the SQL query

rsSIM.Open strSQL, adoCon

wscript.echo rsSIM("Total")

It works perfectly in vbs, but when I try to convert it to AutoIT, it/I fail(s) miserably. I have tried using the SQL.au3 include, and the output that I get from my query is "ÿÿ|" when in fact it should be "63". WTF?!

Any help would be greatly appreciated.

Posted

@Gnat

something like this ?

;'Create an ADO connection object

$adoCon = ObjCreate("ADODB.Connection")

;'Set an active connection to the Connection object using a DSN-less connection
$adoCon.Open "SIM"
$rsSIM = ObjCreate("ADODB.Recordset")

;'Initialise the strSQL variable with an SQL statement to query the database
$strSQL = "SELECT count (*) as Total from devices where overallstatus='0';"

;'Open the recordset with the SQL query
$rsSIM.Open ($strSQL, $adoCon)

consolewrite( $rsSIM("Total") )

regards

ptrex

Posted (edited)

@Gnat

something like this ?

;'Create an ADO connection object

$adoCon = ObjCreate("ADODB.Connection")

;'Set an active connection to the Connection object using a DSN-less connection
$adoCon.Open "SIM"
$rsSIM = ObjCreate("ADODB.Recordset")

;'Initialise the strSQL variable with an SQL statement to query the database
$strSQL = "SELECT count (*) as Total from devices where overallstatus='0';"

;'Open the recordset with the SQL query
$rsSIM.Open ($strSQL, $adoCon)

consolewrite( $rsSIM("Total") )

regards

ptrex

Unfortunately, I get a similar response as noted in my original post...I made a couple of changes to it...

$adoCon = ObjCreate("ADODB.Connection")

$adoCon.Open("SIM")

$rsSIM = ObjCreate("ADODB.Recordset")

$strSQL = "SELECT count (*) as Total from devices where overallstatus='0';"

$rsSIM.Open ($strSQL, $adoCon)

MsgBox(0, "Unknown", $rsSIM("Total"))

Is the MsgBox messing with it?

I get ÿÿ2 as the result...any other ideas?

Edited by Gnat
Posted

I get ÿÿ2 as the result...any other ideas?

getting binary goop back indicates that you are trying to consolewrite an object, rather than the result of an expression...

test $rsSIM("Total") with IsObj() to verify hypothesis.

Try the object.property syntax, if total is supposed to be a property of $rSIM --> consolewrite($rSim.Total)

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

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
×
×
  • Create New...