ASP.net数据库连接问题!在线等待,谢谢!
ASP.net数据库连接问题!
请教各位大虾,我刚刚使用ASP.net写点东西,在使用SQLConnection(ADOConnection)时出错,不知是何原因》代码如下:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>
<html>
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As New SQLConnection("server='10.52.16.123';uid=sa;pwd=sa;database=SPARE")
Dim MyCommand As SQLDataSetCommand
'同数据库进行连接,采用sql server数据库
'MyConnection = New SQLConnection("server='iceberg';uid=sa;pwd=;database=info")
'执行SQL操作
MyCommand = New SQLDataSetCommand("select * from USER_LIST",MyConnection)
DS = New DataSet()
MyCommand.FillDataSet(ds, "USER_LIST")
MyDataGrid.DataSource=ds.Tables("USER_LIST").DefaultView
MyDataGrid.DataBind()
End Sub
</script>
<center>
<body>
<h3><font face="Verdana">Page_load事件演示</font></h3>
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="600"
BackColor="white"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
MaintainState="false"
/>
/body>
</center>
</html>
调试时的错误如下:
“/WebApp2”应用程序中的服务器错误。
--------------------------------------------------------------------------------
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: BC30002: 未定义类型“SQLConnection”。
源错误:
行 6: Sub Page_Load(Src As Object, E As EventArgs)
行 7: Dim DS As DataSet
行 8: Dim MyConnection As New SQLConnection("server=(local);uid=sa;pwd=;database=BPBJ")
行 9: Dim MyCommand As SQLDataSetCommand
行 10: '同数据库进行连接,采用sql server数据库
源文件: http://localhost/WebApp2/pagedata.aspx 行: 8