asp.net如何访问mysql?
hhl00 2003-09-11 11:55:41 站内有一些相关文章,但是就是不行,我使用的是 ODBC.NET Provider和 MySQL ODBC Driver-MyODBC 3.51,我的测试代码如下:
<%@ Page Language="vb" Debug="true" %>
<%@ Import Namespace="Microsoft.Data.Odbc" %>
<%@ Import Namespace="system.data" %>
<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;userid=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" />
哪里不行呢?