Jump to content

connecting Autoit and mysql


Subin
 Share

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


 

Link to comment
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
Link to comment
Share on other sites

  • Moderators

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

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

 
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...