使用VBA查找Windows中安装的MySQL ODBC驱动程序的版本
使用 Visual Basic for Applications,如何查明用户计算机上的 Windows 中安装了哪个版本的 MySQL ODBC 驱动程序?
我有一个 Microsoft Access 应用程序,它使用 MySQL ODBC 驱动程序进行连接。连接字符串如下所示:
ODBC;DATABASE=mydatabase;DRIVER={MySQL ODBC 3.51 Driver};
OPTION=3;PWD=password;PORT=3306;SERVER=server-db;UID=db-user;
这是工作查找,直到 IT 经理在用户 PC 上安装了 5.1 版 MySQL ODBC 驱动程序,这破坏了我的连接字符串。
如果我知道用户的 Windows XP 安装上安装的驱动程序版本,我可以在运行时将其插入到连接字符串中。 如何使用 VBA 查明用户计算机上的 Windows 中安装了哪个版本的 MySQL ODBC 驱动程序?
Using Visual Basic for Applications, how can I find out which version of the MySQL ODBC driver is installed in Windows on a user's machine?
I have a Microsoft Access application that uses the MySQL ODBC driver to make a connection. The connection string looks like this:
ODBC;DATABASE=mydatabase;DRIVER={MySQL ODBC 3.51 Driver};
OPTION=3;PWD=password;PORT=3306;SERVER=server-db;UID=db-user;
This was working find until the IT manager installed version 5.1 of the MySQL ODBC driver on a user's PC, which broke my connection string.
If I knew the version of the driver installed on the user's Windows XP installation, I could insert that into the connection string at run-time. How can I find out which version of the MySQL ODBC driver is installed in Windows on a user's machine using VBA?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在注册表中
使用此处找到的信息找到它,您可以获取它使用下面的代码(我在Access 97中测试过)
You can find it in the registry under
Using the info found here, you can get at it using the below code (I tested it in Access 97)
以下是一些可能的想法:
1 您可以检查注册表并查找特定键,例如: [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\MySQL ODBC 3.51 Driver]
2.您可以检查他们的 c :\windows\system32文件夹下找到myodbc.dll,然后查看版本信息。这是有关如何检查版本的链接:
http://www.vb-helper.com/howto_file_version_info.html
Here are a few possible ideas:
1 You may be able to check the registry and look for specific keys, like this for example: [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\MySQL ODBC 3.51 Driver]
2.You could check their c:\windows\system32 folder for the myodbc.dll, and then check the version information. Here's a link on how to check the version:
http://www.vb-helper.com/howto_file_version_info.html
如果您想避免根据具体情况处理版本,您可以迭代键值,例如..
此函数旨在枚举 ODBC 驱动程序的注册表键,并仅检查某处是否存在 mysql,如果不存在,它将警告用户,然后将他们带到下载页面,并提醒他们获取适合其架构的正确版本 (32/64)
并且您将需要它来枚举注册表项(有关更多信息,请参阅 http://technet.microsoft.com/en-us/library/ee176771.aspx):
If you want to avoid handling versions on a case by case basis you can iterate through the key values, eg..
This function is designed to enumerate through the regkeys for ODBC drivers and just check for the existance of mysql somewhere, if not it will warn the user then take them to the download page, and remind them to get the right version for their architecture (32/64)
And you'll need this to enumerate the reg keys (for more on this see http://technet.microsoft.com/en-us/library/ee176771.aspx):