Jump to content

Need Help converting vbs MS SQL script to AutoIT...


Gnat
 Share

Recommended Posts

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.

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

@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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Try

ConsoleWrite($oSIM.Fields(0).Value)oÝ÷ Ù±!?Ûj[(¶¼ºÚ"µÍÌÍÜÝÔSH   ][ÝÔÑSPÕÛÝ[

HÛH]XÙÈÚHÝ[Ý]ÏIÌÎNÌ   ÌÎNÉ][Ý

note: without ending char ";"

And also search forum for examples , as keyword use "ObjCreate ("ADODB.Recordset")"

Edited by Zedna
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...