ADOConnection未定义??
程序:
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<html>
<script language="VB" runat="server">
Sub Page_Load(Src As Object,E As EventArgs)
Dim ConnectionString,SQLString As String
Dim MyConnection As ADOConnection
Dim MyCommand As ADOCommand
Dim DR As ADODataReader
ConnectionString="FileDSN=authorsforstudy"
SQLString="select * from authors"
MyConnection=New ADOConnection(ConnectionString)
MyCommand=New ADOCommand()
MyCommand.CommandType=CommandType.Text
MyCommand.CommandText=SQLString
MyCommand.ActiveConnection=MyConnection
MyCommand.ActiveConnection.open
MyCommand.Execute(DR)
MyDataGrid.DataSource=DR
MyDataGrid.DataBind()
End Sub
</script>
<body>
<h3><font face="宋体">访问ODBC数据源简单示例</font></h3>
<!--声明一个DataGrid控件-->
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="skyblue"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="宋体"
Font-Size="10pt"
HeaderStyle-BackColor="lightblue"
MaintainState="false"/>
</body>
</html>
错误:
Server Error in '/example' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30002: Type 'ADOConnection' is not defined.
Source Error:
Line 6: Sub Page_Load(Src As Object,E As EventArgs)
Line 7: Dim ConnectionString,SQLString As String
Line 8: Dim MyConnection As ADOConnection
Line 9: Dim MyCommand As ADOCommand
Line 10: Dim DR As ADODataReader
Source File: D:\example\ex6_1.aspx Line: 8