1

Resolved

Add support for later version of MySQL ODBC driver

description

Currently the checkRequirements.vbs script checks explicitly for the 3.51 ODBC driver. There are considerably later versions available for download from mysql.org. The test being used requires accessing the registry under an explicit key (it seems like there should be an easier way). Presently that key is
 
iODBCVersion = getRegistryKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A854ED3-C3B1-493D-8104-C4B5AC459B7A}", "DisplayVersion", False)
 
The 5.1 version uses a different key (this is probably an error, but it's outside your control). On my box, that key is:
 
iODBCVersion = getRegistryKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{29042B1C-0713-4575-B7CA-5C8E7B0899D4}", "DisplayVersion", False)
 
Please note that if the geniuses at MySQL continue to make this error, the x64 version of the driver will likely have a different key yet again.
 
I've added my own support for this key, but I'm not really a VB coder, so this probably isn't a very good way to do it.
 
Function checkMySQLODBC ()
Dim iODBCVersion, oShell
 
On Error Resume Next
 
iODBCVersion = getRegistryKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9A854ED3-C3B1-493D-8104-C4B5AC459B7A}", "DisplayVersion", False)
 
if Not iOBBCVersion Is NullString Then
    Session.Property("MYSQL_ODBC_DRIVER") = "MySQL ODBC 3.51 Driver"
 
    If iODBCVersion >= "3.51.21" Then
        Session.Property("SQLSERVERCheck") = "OK"
        checkMySQLODBC = ERROR_SUCCESS
    Else
        Session.Property("SQLSERVERCheck") = "BAD"
        checkMySQLODBC = ERROR_INSTALL_FAILURE
    End If
 
    Exit Function
End If
 
'{29042B1C-0713-4575-B7CA-5C8E7B0899D4} is the key for ODBC 5.1. There must be a better way to do this.
iODBCVersion = getRegistryKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{29042B1C-0713-4575-B7CA-5C8E7B0899D4}", "DisplayVersion", False)
 
if Not iOBBCVersion Is NullString Then
    Session.Property("MYSQL_ODBC_DRIVER") = "MySQL ODBC 5.1 Driver"
 
    If iODBCVersion >= "5.1.0" Then
        Session.Property("SQLSERVERCheck") = "OK"
        checkMySQLODBC = ERROR_SUCCESS
    Else
        Session.Property("SQLSERVERCheck") = "BAD"
        checkMySQLODBC = ERROR_INSTALL_FAILURE
    End If
 
    Exit Function
End If
 
' Explain why odbc drive is need
iAnswer = MsgBox("In order to enable this installer to setup a " &_
    "MySQL Database, this machine requires a MySQL ODBC Connector. " &_
    "I could not find either a v3.51.x or a v.5.1.x version installed. " &_
    "These drivers can be obtained from: " & vbCrLf & vbCrLf &_
    "|- http://dev.mysql.com/downloads/connector/odbc" & vbCrLf &_
    "|-- Windows downloads" & vbCrLf &_
    "|--- Windows MSI Installer (x86)" & vbCrLf & vbCrLf &_
    "Do you want to open this URL?", 36, "MySQL ODBC Connector missing...")
 
If Not iAnswer = 7 Then
    Set oShell = CreateObject("Shell.Application")
    oShell.ShellExecute Session.Property("IEXPLOREEXE"), "http://dev.mysql.com/downloads/connector/odbc", "", "open", 1
End if
 
Session.Property("SQLSERVERCheck") = "BAD"
checkMySQLODBC = ERROR_INSTALL_FAILURE
End Function

comments

bernhardfrank wrote Oct 20, 2008 at 9:05 AM

Hi Austin,

added this functionality in version 2.0.10 - rather than querying the registry I use windows installer to query for odbc connector packages:

'we ask windows installer database whether a MySQL Connector/ODBC is installed
Set wiInstaller = CreateObject("WindowsInstaller.Installer")
for each product in wiInstaller.Products
productName = wiInstaller.ProductInfo(product,"ProductName")
if (InStr(1, productName,"MySQL Connector/ODBC") <> 0) then
    select case productName
        case "MySQL Connector/ODBC 3.51"
            Session.Property("MYSQL_ODBC_DRIVER") = "MySQL ODBC 3.51 Driver"
        case "MySQL Connector/ODBC 5.1"
            Session.Property("MYSQL_ODBC_DRIVER") = "MySQL ODBC 5.1 Driver"
        case else 'best guess
            VersionMajor = wiInstaller.ProductInfo(product,"VersionMajor")
            VersionMinor = wiInstaller.ProductInfo(product,"VersionMinor")
            Session.Property("MYSQL_ODBC_DRIVER") = "MySQL ODBC " & VersionMajor & "." & VersionMinor & " Driver"
    end select
    Session.Property("SQLSERVERCheck") = "OK"
    checkMySQLODBC = ERROR_SUCCESS
    Exit Function   
end if
next
set wiInstaller = nothing


this works for me.

Thanks for the hint

Bernhard

wrote Apr 1, 2009 at 4:50 PM

wrote Feb 14, 2013 at 1:23 AM

wrote May 16, 2013 at 4:40 AM

wrote May 16, 2013 at 4:40 AM

wrote Jun 14, 2013 at 7:52 AM