Sign in to follow this  
Followers 0
Subin

connecting Autoit and mysql

9 posts in this topic

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



Such as the mysql UDF at this link:


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Subin

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

i am coonecting using MySQL ODBC 3.51 Driver

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

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  
Followers 0