Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mysql QM connect
#1
i am able to connect QM with .mdb file and it work perfectly OK.
But i doesn't connect with any other database, eg mysql.
Does QM supports mysql, if yes, please let me know the code for it. it is very urgent.
I have purchased licence for QM.

company name Pixlinc and owner name Ajay sagar.
#2
Look at the examples under QM folder: System->Functions->Database->Database help
I have used them successfully. What problems were you having?
Matt B
#3
i already read that, but it support only .mdb database i.e access database and not mysql????????????????HELP..........
#4
Darn it, I misread your post. I'm sorry. I'm not sure of an answer at the moment. I would start by interfacing QM with command line mySql tools.
Matt B
#5
This is example for mysql. Connects to local MySQL server as user 'root' (it is default user), password 'p' (you set it in MySQL server instance config wizard), and selects initial database 'menagerie'. Then shows contents of table 'pet'.

Macro
Code:
Copy      Help
Database db.Open("DRIVER={MySQL ODBC 5.1 Driver};DATABASE=menagerie;USER=root;PASSWORD=xxxx;")
ARRAY(str) a; int r c
db.QueryArr("SELECT * FROM pet" a)
for r 0 a.len(2)
,out "-- Record %i --" r+1
,for c 0 a.len(1)
,,out a[c r]

You need Connector/ODBC - MySQL ODBC driver.

http://dev.mysql.com/downloads/

If you have driver version 3.51, replace 5.1 to 3.51.


To connect to a remote database (if the web server allows it and you know all the parameters) can be used code like this:
Macro
Code:
Copy      Help
Database db.Open("Driver={MySQL ODBC 5.1 Driver};Server=db1.database.com;Port=3306;Option=131072;Database=mydb;Uid=myUsername;Pwd=myPassword")
#6
I wanted to test if I could get this working, but I had some problems.
I resolved it by using the 2 below described methods.
Please do not assume the below is a correct/best practice way to properly setup a ODBC connector but if you can not connect or getting errors the below might help.

I anyone else has some other (better) trick, methods or info about this, please post it here.
I think this QM feature very interesting!
If I explained something wrong or made incorrect assumptions, my apologies.

METHOD 1: Using installer

If you are 100% sure you already installed the ODBC connecter correctly BUT get the following error

Quote:Connector/ODBC :: Data Provider or other service returned an E_FAIL status Error

Then scroll below to the bottom of this post, there might be a possible solution.

  1. If you get an error during installation of MySQL ODBC connector
    install vistual studio redist
    topic: http://forums.mysql.com/read.php?37,599399,599399
    download: http://dev.mysql.com/downloads/connector/odbc/
    vcredist_x64.exe: rehttp://www.microsoft.com/en-us/downlo ... x?id=14632
    vcredist_x86.exe: http://www.microsoft.com/en-us/download ... px?id=5555
    I used _86 on a 64 bit machine, it should work


  2. step 1: Control Panel >> System and Security >> Administrative Tools >> double click: "Data Sources (ODBC)"
    step 2: click SECOND tab "System DSN" >> click button "Add" (on the right) >> Select the MYSQL ansi / unicode
    step 3: input your database and table connection parameters, then test it
    2 minute youtube tutorial: http://www.youtube.com/watch?v=K3GZidOwGmM

METHOD 2: Using commandline


It contains an unusual step, but it worked on my machine...
  1. Download the ZIP NOINSTALL version:
    download: http://dev.mysql.com/downloads/connector/odbc/
    - Windows (x86, 32-bit), ZIP Archive
    - Windows (x86, 64-bit), ZIP Archive
    Unpack it to a folder.


  2. Normally the install.bat should be working, but it is not installing properly (getting error)
    inspecting the install.bat I noticed the target dirs in the install.bat are not 100% ok (at least I think it is not ok)
    I did not want to spend time on correcting it.
    So I read the following:
    http://dev.mysql.com/doc/connector-odbc ... s-dll.html
    And executed those steps (except for step 6, copying the help files, because there werent any).
    The final step (7) is described below at '3'


  3. step 7 executing the command, the command is not displayed in a copy and paste in CMD manner.
    If you copy an paste it, it will look like this:

    myodbc-installer -a -d -t"MySQL ODBC 5.2 Driver;\
    DRIVER=myodbc5a.dll;SETUP=myodbc5S.dll"

    I tried to reconstruct the correct commandline but the '\' was giving me troubles
    I finally came up with something like this:
    Code:
    Copy      Help
    f:\_____TMP\mysql_connector\bin\myodbc-installer.exe -a -d -n "MySQL ODBC 5.3 Driver" -t DRIVER=myodbc5a.dll;SETUP=myodbc5S.dll

    Change the location of the "myodbc-installer.exe" to your location.

    tip: open commandline and just drag the "myodbc-installer.exe" into the cmd window and press [ENTER]
    the help-info should display some correct examples.

    the driver should install correct BUT it does not show up in the "ODBC Data Source Administrator"
    Control Panel >> System and Security >> Administrative Tools >> double click: "Data Sources (ODBC)"


  4. The unusual step I mentioned: This final step is a bit weird, double click the "install.bat" from step '1'
    DO NOT DRAG IT INTO THE CMD WINDOW... (if you drag it into the CMD window OR type the path in that CMD window and press [ENTER]
    the example QM code above will not work).
    But if you double click the "install.bat" and then run the QM code, it works.
    After double clicking the "install.bat" Another CMD window pops up very briefly I could not read the contents.

    The commandline method does not display anything in the "ODBC Data Source Administrator"
    Control Panel >> System and Security >> Administrative Tools >> double click: "Data Sources (ODBC)"
    And it seems you don't have to add a DSN connection like explained in the youtube tutorial (when using the installer).


  5. finally, check if the drivers are installed:
    Quote:f:\_____TMP\mysql_connector\bin\myodbc-installer.exe -d -l
    Change "myodbc-installer.exe" path to your unpacked path


!!! very important things !!!
  • Do not connect to a database that contains EMPTY/NULL/ILLEGAL DATES
    Quote:Data Provider or other service returned an E_FAIL status Error

    http://forums.mysql.com/read.php?37,497 ... msg-142962
    http://www.roseindia.net/mysql/Data-Pro ... rror.shtml
    Solution first test the connection on a very simple database with a simple table (for example a table containing simple names, no exotic characters.)
    Then start using the ODBC connector on complext databases and such, but make sure DATE tables contain VALID dates (and not empty/NULL)
    NOTE: I assume for the time beeing this is a correct approach as I could not find another solution.


  • Use CORRECT connection strings, if you use ANSI mysql ODBC:
    QM CODE: Database db.Open("Driver={MySQL ODBC 5.3 ANSI Driver};Server= ...
    https://www.connectionstrings.com/mysql/


  • Adjust the version like explained above
    Quote:If you have driver version 3.51, replace 5.1 to 3.51.

The 2 methods were done on Windows 7 64bit machine (UAC turned off, I use other security measures).
I only used the 32bit version (_x86) of "vcredist" and the mysql ODBC connector.


Forum Jump:


Users browsing this thread: 1 Guest(s)