为何我的asp.net连接不上mysql?
hhl00 2003-09-12 07:00:54 以下是我在Dreamweaver中的代码:
<%@ Page Language="vb" Debug="true" %>
<%@ Import Namespace="Microsoft.Data.Odbc" %>
<html>
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim myconnection As New OdbcConnection("DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=data;uid=dbuser;password=192168;option=3")
Dim mycommand As OdbcCommand() = New OdbcCommand()("SELECT * FROM student", myconnection)
mycommand.Open()
dim read as OdbcDataReader
read=mycommand.ExecuteReader()
show.DataSource=read
show.DataBind()
read.Close()
mycommand.Close()
end sub
</script>
<asp:DataGrid id="show" runat=server HeaderStyle-
BackColor="#aaaadd" />
出错情况为:未定义类型“OdbcConnection”
我已经安装了MyODBC-3.51,在“控制面板”中的“数据源”下建立了一个dsn,测试可以连接!