Gnat Posted April 13, 2007 Share Posted April 13, 2007 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 More sharing options...
Gnat Posted April 13, 2007 Author Share Posted April 13, 2007 ^Nudge^ Any help? Link to comment Share on other sites More sharing options...
ptrex Posted April 13, 2007 Share Posted April 13, 2007 @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 Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Gnat Posted April 13, 2007 Author Share Posted April 13, 2007 (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 April 13, 2007 by Gnat Link to comment Share on other sites More sharing options...
Gnat Posted April 16, 2007 Author Share Posted April 16, 2007 ^Nudge^ Anybody else? Any SQL help...any new UDFs...anything? Link to comment Share on other sites More sharing options...
flyingboz Posted April 16, 2007 Share Posted April 16, 2007 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 More sharing options...
Zedna Posted April 16, 2007 Share Posted April 16, 2007 (edited) 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 April 16, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now