xp系统mysql odbc_MySql ODBC Windows XP到Windows 7。

I am trying to port a large application from Windows XP to Windows 7. This application MUST work on both platforms side by side as I have 22 client machines and they are all currently Windows XP but will one by one over time be converted to Windows 7.

我試圖將一個大的應用程序從Windows XP移植到Windows 7。這個應用程序必須同時在兩個平台上運行,因為我有22台客戶端機器,它們都是當前的Windows XP,但隨着時間的推移,它們將被轉換為Windows 7。

I have a MySql database that works fine in XP and has been for a few years. On my first Windows 7 machine, it fails when I run the line of code to open a connection to the db:

我有一個MySql數據庫,它在XP系統中運行良好,已經運行了幾年。在我的第一台Windows 7機器上,當我運行代碼行來打開與db的連接時,它失敗了:

MyOdbcConnection.Open()

MyOdbcConnection.Open()

The error is "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".

錯誤是“錯誤[IM002][微軟][ODBC Driver Manager]數據源名稱未找到,且沒有指定默認驅動程序”。

To try to fix it, I downloaded the latest ODBC 5.2 drivers from MySql. I downloaded BOTH the 32bit and 64bit ones. I went into the ODBC Data Source Administrator for BOTH the 32bit and 64bit and added my datasource successfully for this db for a User DSN, System DSN, and File DSN. I can also successfully connect to the db from the MySql workbench.

為了解決這個問題,我從MySql下載了最新的ODBC 5.2驅動程序。我下載了32位和64位。我為32位和64位訪問了ODBC數據源管理員,並成功地為這個數據庫添加了數據源DSN、系統DSN和文件DSN。我還可以從MySql工作台成功地連接到數據庫。

This is my connection string. It's the same as the other working machine except that one is using the 5.1 driver.

這是我的連接字符串。它和其他工作機器一樣,只是使用了5.1驅動程序。

Dim MySqlConString As String = "DRIVER={MySQL ODBC 5.2 Driver};" & _ "SERVER=myserver;" & _ "DATABASE=mydb;" & _ "UID=root;" & _ "PASSWORD=mypw;" & _ "OPTION=3" – Jason Shoulders 3 hours ago

Despite being able to add the data source and connect to the db via workbench, I continue to get an error when I run my exe. Any suggestions?

盡管能夠添加數據源並通過工作台連接到db,但在運行exe時,仍然會出現錯誤。有什么建議嗎?

4 个解决方案

#1

0

Apparently I needed to have:

顯然我需要:

DRIVER={MySQL ODBC 5.2w Driver}

Seems lame. I'm not sure where the "w" came from.

似乎站不住腳的。我不知道“w”是從哪里來的。

#2

0

There is little point in adding a user, system and file DSN as your code is not using any of them. You are using what is usually referred to as a "DSN-less" connection. If you were using any of your created DSNs your connection string would be "DSN=my_created_dsn" or FILEDSN=path_to_file. As you are using "DRIVER={xxx}" all you are doing is telling the ODBC driver manager which driver to load and the other attributes in the connection string tell the driver what mysql db to connect to. The name you use for xxx needs to be exactly the name of the driver as shown in the odbc drivers tab. If you are going to continue connecting like this you can delete all your DSNs.

添加用戶、系統和文件DSN是沒有意義的,因為您的代碼沒有使用其中任何一個。您正在使用通常被稱為“dsnless”的連接。如果您使用任何創建的DSNs,您的連接字符串將是“DSN=my_created_dsn”或FILEDSN=path_to_file。當您使用“DRIVER={xxx}”時,您所要做的就是告訴ODBC驅動程序管理器,該驅動程序將加載哪個驅動程序,以及連接字符串中的其他屬性告訴驅動程序要連接的mysql db。您為xxx所使用的名稱必須恰好是驅動程序的名稱,如odbc driver選項卡所示。如果你繼續這樣連接,你可以刪除所有的DSNs。

#3

0

Your 32bit program will not find a 64bit odbc driver. Try setting up the 32bit driver with the following in a command window

您的32位程序將不會找到64位的odbc驅動程序。嘗試在命令窗口中設置32位驅動程序。

%WINDIR%\syswow64\odbcad32.exe

#4

0

I'm using Visual Fox Pro 9.0 under Windows XP Pro SP3 with 32 bit

我使用的是Visual Fox Pro 9.0, Windows XP Pro SP3和32位。

I had the same problem but id did NOT work with:

我也有同樣的問題,但我沒有工作:

Driver={MySQL ODBC 5.2a Driver} or with Driver={MySQL ODBC 5.2w Driver}

驅動程序={MySQL ODBC 5.2a驅動程序}或與驅動程序={MySQL ODBC 5.2w驅動程序}

IT WORKED!!! with:

成功了! ! !:

Driver={MySQL ODBC 5.2 ANSI Driver} or with Driver={MySQL ODBC 5.2 UNICODE Driver}

驅動程序={MySQL ODBC 5.2 ANSI驅動程序}或使用驅動={MySQL ODBC 5.2 UNICODE驅動程序}

Try it.

試一試。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值