Monday 29 October 2012

Problem with Mysql ODBC VB.NET

      I recently had a problem connecting to an MYSQL database that had been working OK for months. I had move the program from one machine to another created all the ODBC  links etc. but it failed to work.
The problem was that I had move it to a 64 bit machine now there was a couple of things that have come out of this.

If you are working in a 32 bit application then you need to use a 32 bit driver not the 64 bit one you may have on the machine.

To make matters worse you need to open the Odbc Window in 32 bit format (do not for get to install it first) from the command prompt
c:\windows\sywow64\odbcad32.exe (you can browse to it via explorer)
enter the ODBC Data.

   You then need to change  the connection string in your code, if you just do the line for a 64 bit machine then it will not run on a 32 bit one. so you could try this.


 Dim connectionString As String
                If Registry.LocalMachine.OpenSubKey("Hardware\Description\System\CentralProcessor\0").GetValue("Identifier").ToString.Contains("x86") Then
                    connectionString = "Driver={MySQL ODBC 5.1 Driver};Server= server address ;Database=dbname User=name;Password=password;Option=3;"
                Else
                    connectionString = "Provider=MSDASQL;Driver={MySQL ODBC 5.1 Driver};Server=dbaddress;Database=dbname;User=user Name;Password=password ;Option=3;"
                End If
this will pick which string to use for a 32 or 64 bit machine.

No comments:

Post a Comment

Passwords Made Easy

Today i thought i would write about password security. As we are all aware passwords are important but we continue to use very poor password...