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?
DRIVER={MySQL ODBC 5.1 Driver};
, but I'm still getting the same error – Curt