Uncle Argyle Posted August 24, 2006 Share Posted August 24, 2006 Hi everyone, I am writing a script where I am making a simple query to a MySQL database on a remote computer. Regardless of how I structure my query, the result comes back as m`*|-$D (Where * is actually a square, but I didn't know how to post that) what am I doing wrong? I am running AutoIT beta 3.1.1.119 and have copied the latest MySQL.au3 into my include directory. I have also install the mysql odbc driver and can successfully query the database from excel. Thanks, Mike. expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: A.N.Other <myemail@nowhere.com> ; ; Script Function: ; Template AutoIt script. ; ; ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstants.au3> #include <String.au3> #include <MySQL.au3> ; == GUI generated with Koda == Opt("TrayIconHide", 1) Opt("GUICloseOnESC", 0) $Form1 = GUICreate("Worksheet Login", 270, 142, 450, 271) $Input1 = GUICtrlCreateInput("", 112, 24, 121, 24, -1, $WS_EX_CLIENTEDGE) $Input2 = GUICtrlCreateInput("", 112, 56, 121, 24, $ES_PASSWORD, $WS_EX_CLIENTEDGE) GUICtrlCreateLabel("Username:", 32, 24, 70, 24, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("Password:", 32, 56, 67, 24, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("OK", 48, 104, 75, 25, $BS_DEFPUSHBUTTON) $Button2 = GUICtrlCreateButton("Cancel", 152, 104, 75, 25) $objErr = ObjEvent("AutoIt.Error","MyErrFunc") $db = _MySQLConnect("admin","pass1234","ssbcrw", "10.1.1.27") GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 $user = GUICtrlRead($Input1) $checkuser = _Query($db,"SELECT authority FROM users WHERE username = '" & $user & "'") MsgBox(0,"test","checkuser = " & $checkuser) ExitLoop EndSelect WEnd Exit Func MyErrFunc() $hexnum=hex($objErr.number,8) Msgbox(0,"","We intercepted a COM Error!!" & @CRLF & @CRLF & _ "err.description is: " & $objErr.description & @CRLF & _ "err.windescription is: " & $objErr.windescription & @CRLF & _ "err.lastdllerror is: " & $objErr.lastdllerror & @CRLF & _ "err.scriptline is: " & $objErr.scriptline & @CRLF & _ "err.number is: " & $hexnum & @CRLF & _ "err.source is: " & $objErr.source & @CRLF & _ "err.helpfile is: " & $objErr.helpfile & @CRLF & _ "err.helpcontext is: " & $objErr.helpcontext _ ) exit EndFunc Link to comment Share on other sites More sharing options...
sshrum Posted August 24, 2006 Share Posted August 24, 2006 (edited) I'm familiar with AutoIT and MySQL but I haven't used them together. However... I'm pretty sure that _Query() is going to return an array (of columns and rows)...not a string even if the result returns 1 field/1 record Look at the _Query function for it's return value. Edited August 24, 2006 by sshrum Sean Shrum :: http://www.shrum.net All my published AU3-based apps and utilities 'Make it idiot-proof, and someone will make a better idiot' Link to comment Share on other sites More sharing options...
Uncle Argyle Posted August 24, 2006 Author Share Posted August 24, 2006 I'm familiar with AutoIT and MySQL but I haven't used them together.However...I'm pretty sure that _Query() is going to return an array (of columns and rows)...not a string even if the result returns 1 field/1 recordLook at the _Query function for it's return value.OK, that makes sense. I'll check into that!Thanks!Mike. Link to comment Share on other sites More sharing options...
ame1011 Posted August 24, 2006 Share Posted August 24, 2006 OK, that makes sense. I'll check into that! Thanks! Mike. It actually returns an object. You'll ahve to use the following to get your info: $var = _Query($db,"SELECT authority FROM users WHERE username = '" & $user & "'") $authority = $var.Fields.("authority").value [font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font] Link to comment Share on other sites More sharing options...
Uncle Argyle Posted August 25, 2006 Author Share Posted August 25, 2006 It actually returns an object. You'll ahve to use the following to get your info: $var = _Query($db,"SELECT authority FROM users WHERE username = '" & $user & "'") $authority = $var.Fields.("authority").value Thanks to both sshrum and ame1011 for your help. Link to comment Share on other sites More sharing options...
Uncle Argyle Posted August 26, 2006 Author Share Posted August 26, 2006 It actually returns an object. You'll ahve to use the following to get your info: $var = _Query($db,"SELECT authority FROM users WHERE username = '" & $user & "'") $authority = $var.Fields.("authority").value I am getting an the following error $authority = $var.Fields.("authority").value $authority = $var.Fields.("authority")^ERROR Object referenced outside a "with" statement. So going by the example in MySQL UDF post, I added a with statement...and still now get an error in expression $authority = .Fields.("authority").value $authority = ^ERROR Usually I can figure this stuff out with a little searching...but, this MySQL is kickin' my butt. Thanks to all... expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: A.N.Other <myemail@nowhere.com> ; ; Script Function: ; Template AutoIt script. ; ; ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstants.au3> #include <String.au3> #include <MySQL.au3> ; == GUI generated with Koda == Opt("TrayIconHide", 1) Opt("GUICloseOnESC", 0) $Form1 = GUICreate("SSB Credit Worksheet Login", 270, 142, 450, 271) $Input1 = GUICtrlCreateInput("", 112, 24, 121, 24, -1, $WS_EX_CLIENTEDGE) $Input2 = GUICtrlCreateInput("", 112, 56, 121, 24, $ES_PASSWORD, $WS_EX_CLIENTEDGE) GUICtrlCreateLabel("Username:", 32, 24, 70, 24, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("Password:", 32, 56, 67, 24, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("OK", 48, 104, 75, 25, $BS_DEFPUSHBUTTON) $Button2 = GUICtrlCreateButton("Cancel", 152, 104, 75, 25) $objErr = ObjEvent("AutoIt.Error","MyErrFunc") $db = _MySQLConnect("tcadmin","s9o1u0t3","ssbcrw", "10.206.1.27") GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 $user = GUICtrlRead($Input1) $var = _Query($db,"SELECT authority FROM users WHERE username = '" & $user & "'") With $var $authority = .Fields.("authority").value MsgBox(0,"test","checkuser = " & $authority) EndWith ExitLoop EndSelect WEnd _MySQLEnd($sql) Exit Func MyErrFunc() $hexnum=hex($objErr.number,8) Msgbox(0,"","We intercepted a COM Error!!" & @CRLF & @CRLF & _ "err.description is: " & $objErr.description & @CRLF & _ "err.windescription is: " & $objErr.windescription & @CRLF & _ "err.lastdllerror is: " & $objErr.lastdllerror & @CRLF & _ "err.scriptline is: " & $objErr.scriptline & @CRLF & _ "err.number is: " & $hexnum & @CRLF & _ "err.source is: " & $objErr.source & @CRLF & _ "err.helpfile is: " & $objErr.helpfile & @CRLF & _ "err.helpcontext is: " & $objErr.helpcontext _ ) exit EndFunc Link to comment Share on other sites More sharing options...
ame1011 Posted August 26, 2006 Share Posted August 26, 2006 (edited) replace $authority = .Fields.("authority").valueoÝ÷ Û«¢+ØÀÌØíÕÑ¡½É¥Ñäô¹¥±Ì ÅÕ½ÐíÕÑ¡½É¥ÑäÅÕ½Ð줹ٱÕoÝ÷ Ø]ب©r§Âäx0ØfÊÊ¥©²ê޶ʷö·¢)àjZ-¡÷«®Üç$x(®Ø^±Êâ¦Ü"W+j.¶ò¢áÞë,¢g)භ*.²Ö«µçZºÚ"µÍÌÍÝÙHÕRPÝXY ÌÍÒ[]JBÙØØH[YØ[ÚXÝ ÌÎNÂYÝ[Ú[Ý ÌÍÝÙ ][ÝÉÌÎNÉ][ÝÊH[ ÌÍÝÙHÝ[ÔXÙH ÌÍÝÙ ][ÝÉÌÎNÉ][ÝË ][ÝÉÌLÉÌÎNÉ][ÝÊB[YÜ[[ÝHÚ]ÜXÙBÙ]Ë]Ë] Edited August 26, 2006 by ame1011 [font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font] Link to comment Share on other sites More sharing options...
Uncle Argyle Posted August 27, 2006 Author Share Posted August 27, 2006 Thanks so much, that did it! Any idea where I can learn more about the syntax about objects and MySQL. Mike. 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