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?
Curt
source share