我正在尝试使用我的ASP.NET Web窗体应用程序连接到
MySQL数据库.我正在进行一项测试,将MysqL数据库中的数据绑定到GridView.
这是我的代码:
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
但是,当建立MysqL数据库连接(MysqLConn.Open())时,会返回以下错误:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not
found and no default driver specified
为什么这样,我怎么能防止它发生?