Jump to content
Sign in to follow this  
Subin

connecting Autoit and mysql

Recommended Posts

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


 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 by Subin

Share this post


Link to post
Share on other sites

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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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.

 

Share this post


Link to post
Share on other sites

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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

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  

×
×
  • Create New...