Subin Posted January 2, 2015 Share Posted January 2, 2015 how to connect auto it and mysql. i tried the below code. but gtting error in line no 15"(15) : ==> Variable must be of type "Object".:" Global $adCN $constrim="DRIVER={MySQL ODBC 5.1 Driver};SERVER=172.16.194.12;DATABASE=crossref;uid=tester;pwd=tester;PORT=3306" $adCN = ObjCreate ("ADODB.Connection") $adCN.Open ($constrim) MsgBox(0,"",$constrim ) if @error Then MsgBox(0, "ERROR", "Failed to connect to the database") Exit Else MsgBox(0, "Success!", "Connection to database successful!") EndIf $sQuery= "SELECT sku FROM products WHERE manufacturer_part_number ='W67003' AND supplier_part_number ='W67003' AND price ='10' AND uom = 'EA'" $result = $adCN.Execute($sQuery) MsgBox(0, "",$result.Fields( "sku" ).Value) $adCN.Close ; ==> Close the database Link to comment Share on other sites More sharing options...
JohnOne Posted January 4, 2015 Share Posted January 4, 2015 I've not done it,but you should take some time to look through the example scripts forum, there are some User Defined Functions there which will help you. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 5, 2015 Moderators Share Posted January 5, 2015 Such as the mysql UDF at this link: "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Subin Posted January 5, 2015 Author Share Posted January 5, 2015 (edited) whats problem on this query Global $adCN $constrim="DRIVER={MySQL ODBC 5.1 Driver};SERVER=172.16.194.12;DATABASE=crossref;uid=tester;pwd=tester;PORT=3306" $adCN = ObjCreate ("ADODB.Connection") $adCN.Open ($constrim) MsgBox(0,"",$constrim ) if @error Then MsgBox(0, "ERROR", "Failed to connect to the database") Exit Else MsgBox(0, "Success!", "Connection to database successful!") EndIf $sQuery= "SELECT sku FROM products WHERE manufacturer_part_number ='W67003' AND supplier_part_number ='W67003' AND price ='10' AND uom = 'EA'" $result = $adCN.Execute($sQuery) MsgBox(0, "",$result.Fields( "sku" ).Value) $adCN.Close ; ==> Close the database Edited January 5, 2015 by Subin Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 5, 2015 Moderators Share Posted January 5, 2015 Did you actually download the driver? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Subin Posted January 5, 2015 Author Share Posted January 5, 2015 i am coonecting using MySQL ODBC 3.51 Driver Link to comment Share on other sites More sharing options...
water Posted January 5, 2015 Share Posted January 5, 2015 You need to add some error handling to see what goes wrong. Have a look at ObjEvent how to add a COM error handler to your script. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
bogQ Posted January 5, 2015 Share Posted January 5, 2015 (edited) I used EzMySql in the past from JLogan3o13 link on post #3 with no problems in Wamp so i did not need to mess with installing ODBC Driver. My question is if have code "DRIVER={MySQL ODBC 5.1 Driver}; and he is using ODBC 3.51 to connect shouldnt that cause some problems? Edited January 5, 2015 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
water Posted January 5, 2015 Share Posted January 5, 2015 Or even easier to get better error information add the following code at the top of your script: #include <Debug.au3> _DebugSetup() _DebugCOMError() My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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