I'm trying to connect to a MySQL database using my ASP.NET Web Forms Application. I'm carrying out a test to Bind the data from the 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 the MySQL database connection is made (MySQLConn.Open()
), the following error is returned:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Why is this and how can I prevent it from happening?
Also, what are the possible reasons for seeing this error? If login credentials were incorrect, would this error be shown?
My problem was that I had on my code
DRIVER={MySQL ODBC 5.3 Driver}, but when I did look up the ODBC trough the windows searcher engine I found an app called ODBC Data Sources, in that app under the Drivers tab I found the name of the drives was {MySQL ODBC 5.3 ANSI Driver}. That fixed the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With