Connecting to MySQL causes the error "Data source name not found and no default driver specified"

I am trying to connect to a MySQL database using an ASP.NET Web Forms application. I am doing a test to bind data from a MySQL database to a GridView .

Here is my code:

 Dim strMySQLConn As String = "DRIVER={MySQL ODBC 5.1 Driver};Database=database_name;Server=ip_address;UID=username;PWD=password;" Dim MySQLConn As New OdbcConnection(strMySQLConn) Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim ds As DataSet = New DataSet() Dim cmdMySQL As New OdbcDataAdapter("SELECT * FROM categorymaster", MySQLConn) MySQLConn.Open() cmdMySQL.Fill(ds, "prjs") gv.DataSource = ds.Tables("prjs").DefaultView gv.DataBind() MySQLConn.Close() End If End Sub 

However, when a connection to the MySQL database is made ( MySQLConn.Open() ), the following error is returned:

ERROR [IM002] [Microsoft] [ODBC Driver Manager] Data source name not found and default driver not specified

Why is it and how can I prevent it?

Also, what are the possible reasons to view this error? If the credentials were incorrect, will this error be displayed?

+7
source share
5 answers

The problem was caused by the fact that I installed the 64-bit MySQL ODBC 5.1 driver because my OS runs on 64 bit.

Because I tried to solve this problem for several days, as a long shot I removed the driver and installed the 32-bit MySQL ODBC 5.1 driver.

This fixed the error and now I am making a successful connection.

+9
source

You might want to check if the driver is installed. Here is a guide to getting the list

Check if you have the installed version, and also make sure that your version matches the one indicated in your connection string.

You should be able to download the driver here.

+3
source

My solution "Data source name not found" (with 5.2.4 ansi ODBC driver, Win7 64 bit):

1) Install the 64-bit MySQL ODBC driver - it should be visible in the ODBC drivers.

2) Install the MySQL 32-bit ODBC driver - it is invisible in ODBC drivers, but create a “shadow” installation in Program Files x86.

What all.

+3
source
Kurt was right. I had this exact problem. Since MySQL Workbench was installed on my workstation, I assumed that I had drivers installed; Nope. Installing the driver plus calling it in the correct version and adding the command "Provider = MSDASQL;" to the connection string due to the fact that I on a 64-bit system solved the problem for me. If you want to see all the ODBC drivers installed on your Windows system, open the registry editor to:

\ HKEY_LOCAL_MACHINE \ SOFTWARE \ ODBC \ ODBCINST.INI \ ODBC Drivers.

There you will find out if the MySQL driver is installed, and if so, its correct name.

This link will take you to the MySQL driver download site.

+3
source

My problem was that I had code

DRIVER = {MySQL ODBC 5.3 Driver}, but when I looked at ODBC through the Windows search engine, I found an application called ODBC Data Sources, in this application, on the "Drivers" tab, I found that the drive name was {MySQL ODBC 5.3 ANSI Driver} . This fixed the problem.

0
source

All Articles