Jump to content
Sign in to follow this  
Gnat

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

Recommended Posts

Gnat

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.

Share this post


Link to post
Share on other sites
Gnat

^Nudge^

Any help?

Share this post


Link to post
Share on other sites
ptrex

@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

Share this post


Link to post
Share on other sites
Gnat

@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

Share this post


Link to post
Share on other sites
Gnat

^Nudge^

Anybody else? Any SQL help...any new UDFs...anything?

Share this post


Link to post
Share on other sites
flyingboz

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.

Share this post


Link to post
Share on other sites
Zedna

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

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  

×