Sign in to follow this  
Followers 0

MySQL ODBC Connection under Vista x64

6 posts in this topic

Hello everybody,

I wanted to run an old script of me under Vista 64Bit, that required MySQL ODBC support to run. I successfully installed the MySQL ODBC driver (I tried version 3.51.26 AND version 5.1!) and I am also able to create a connection with the MySQL Connector GUI.

But when I try to create a connection from my script I always run into an error with the ADODB-Open method, saying the DSN does not exist or the driver is not installed.

Here is my Connection function:

Func _MySQLConnect(Const $S_USERNAME, Const $S_PASSWORD, Const $S_SERVER, Const $S_DATABASE, _
        Const $I_PORT = 3306, Const $I_OPTION = 0, Const $S_DRIVER = "{MySQL ODBC 3.51 Driver}", Const $F_X64 = False)
    Local $s_key = "HKLM"
    If $F_X64 Then $s_key &= "64"
    $s_key &= "\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"
    Local Const $S_VAL = RegRead($s_key, StringMid($S_DRIVER, 2, StringLen($S_DRIVER) - 2))
    If @error Or Not $S_VAL Then Return SetError(2, 0, 0)

    Local $o_adodb = ObjCreate("ADODB.Connection")
    If @error Then SetError(3, 0, 0)

    Local Const $S_CONN = "DRIVER=" & $S_DRIVER & _
            ";SERVER=" & $S_SERVER & _
            ";PORT=" & $I_PORT & _
            ";DATABASE=" & $S_DATABASE & _
            ";UID=" & $S_USERNAME & _
            ";PWD=" & $S_PASSWORD & _
            ";OPTION=" & $I_OPTION & ";"

    $o_adodb.ConnectionString = $S_CONN
    ConsoleWrite($S_CONN & @CRLF)

    If @error Then Return SetError(1, 0, 0)
    Return $o_adodb
EndFunc   ;==>_MySQLConnectoÝ÷ Ø ÝêÞɲ~éܶ*'q©ejëh×6$o_mysql = _MySQLConnect($s_mysqlusername, $s_mysqlpassword, $s_mysqlserver, $s_mysqldatabase, $i_mysqlport, 0, "{MySQL ODBC 3.51 Driver}", true)
    MsgBox(64, "_MySQLConnect", @error)

This worked fine under Windows XP x86, but under Vista x64 it always crashes (enable ErrorHandling for detailed error description!). Does any one know how to solve this problem? Has the connection string to be changed or what is going on?

Share this post

Link to post
Share on other sites

The drivers are different for x86 and x64. Make sure the driver is x64 because sometimes an x86 driver will allow programs to connect but not something calling data.

Share this post

Link to post
Share on other sites

Oh, i forgot to mention. I am using both the x64 ODBC drivers. Is seems that the connection string is not working or has to be changed, but I did not find anything about it on the Internet.

Share this post

Link to post
Share on other sites

#4 ·  Posted (edited)

Well did you download the MySQL.au3 from the forums? If so you have an old one. You need to download it from his website.

Edit: Or did you write this function? It's been a while since I've used the MySQL.au3 file so I can't tell right off.

Edited by dbzfanatic

Share this post

Link to post
Share on other sites

#5 ·  Posted (edited)

I wrote this function...

I cannot reach the URL with the recent version of the MySQL UDFs, but this should work, because it does under Windows XP x86... The root user I am connecting with also has access from the host localhost.

EDIT 1: What I am wondering about is, I've installed both the old and new version of the MySQL ODBC driver for x64, but the drivers are only listed under C:\Windows\System32\odbcad32.exe and not under C:\Windows\SysWOW64\odbcad32.exe where they should be listed in my understanding! From the odbcad32.exe under System32 I can connect to the database without problems with both drivers!

I certainly do not know what to do to solve this problem. Does anyone have Vista x64 and a running MySQL server who can test it? Also, does someone has the recent verson of the UDFs mentioned above and can post it here?

EDIT 2: Below is a screenshot of the error message (with enabled ErrorHandling) and the ODBC Windows Dialog in German language (sorry for that). I just checked the link under Administrative tools that links to C:\Windows\System32\odbcad32.exe, so I think that should be ok...



Edited by tehhahn

Share this post

Link to post
Share on other sites

#6 ·  Posted (edited)

*push* (Sorry for that, but I must solve this problem!)

See above: EDIT 1 and EDIT 2!

Edited by tehhahn

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