Downloaded the latest MySQL ODBC 5.1 Driver from mysql's website, yes, the right version (32-bit for my Windows, check your version - you might need the 64-bit one)
Installed driver.
Created DSN in User DSN (control panel->administrative tools->data sources, and NO, it is NOT needed to create the ODBC Data Source in your System DSN or other, just in User DSN).
Yes, entered correct server name, username, password.
Now going to my C# program, at Connection.Open() - i get the following error: system.data.odbc.odbcexception: error [im002] [microsoft][odbc driver manager] data source name not found and no default driver specified
WHAT in God's name is the problem????
I must say that i've installed and used the mysql odbc connector in the past too, and the connection went smoothly then..
Yes, the problem is the connection string. This is what i had:
ConnStr = "DRIVER={MYSQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=my_database;UID=my_username;PWD=my_password;OPTION=1";
Banged head, ripped clothes off, cut veins, and then success: copy and paste the EXACT ODBC driver name, and now i have this:
ConnStr = "DRIVER={MYSQL ODBC 5.1 Driver};SERVER=localhost;DATABASE=my_database;UID=my_username;PWD=my_password;OPTION=1";
Please notice the string at 'driver=', it must be the same as the ODBC Driver Name, in my case: MYSQL ODBC 5.1 Driver
You find the driver name under Control Panel -> Administrative Tools -> Data Sources (ODBC) , in the 'driver' column (obvious, eh?), next to my own MySQL ODBC Data Source.
Pheewww, that was a bugger.
PS: Oh, and NO, you don't need to add any references to the mysql library either in your project. This is the ODBC method, and you are not using any mysql objects/references here. You must include though your System.Data. If you want to go the mysql .net connection method, search for another post.
Niciun comentariu:
Trimiteți un comentariu