主题:在连接数据库为什么会出现这样的错误
这是我连接数据库时的源代码:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1"%>
<%@import namespace=system.Data %>
<%@import namespace=system.Data.ADO %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体"><INPUT style="Z-INDEX: 101; LEFT: 160px; WIDTH: 350px; POSITION: absolute; TOP: 140px; HEIGHT: 95px" type="text" size="53" runat =server >
<INPUT style="Z-INDEX: 102; LEFT: 185px; WIDTH: 122px; POSITION: absolute; TOP: 318px; HEIGHT: 41px" type="button" value="Button" onserverclick="button1_click" runat=server ></FONT></form>
<script language=vb runat=server >
sub button1_click(sender as object,e as eventargs)
dim cna as ADOConnection=new ADOConnection
dim cma as ADOCommand=new ADOCommand
cna.provider="Microsoft.Jet.OLEDB.4.0"
cna.datasource="e:\asp学习\net\user.mdb"
cna.open()
cma.activeconnection=cna
cma.commandtype=commandtype.text
cma.commandtext=text1.value
cma.execute()
response.write ("影响了") & cma.recordsaffected & ("资料")
end sub
</script>
</body>
</HTML>
但当我执行程序时出现以下错误提示:
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: BC30002: 未定义类型“ADOConnection”。
源错误:
行 18: <script language=vb runat=server >
行 19: sub button1_click(sender as object,e as eventargs)
行 20: dim cna as ADOConnection=new ADOConnection
行 21: dim cma as ADOCommand=new ADOCommand
行 22: cna.provider="Microsoft.Jet.OLEDB.4.0"
说我未定义类型:ADOConnection .这是怎么回事呀。我应该怎么样定义ADOConnection这个类型呀
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1"%>
<%@import namespace=system.Data %>
<%@import namespace=system.Data.ADO %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio .NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体"><INPUT style="Z-INDEX: 101; LEFT: 160px; WIDTH: 350px; POSITION: absolute; TOP: 140px; HEIGHT: 95px" type="text" size="53" runat =server >
<INPUT style="Z-INDEX: 102; LEFT: 185px; WIDTH: 122px; POSITION: absolute; TOP: 318px; HEIGHT: 41px" type="button" value="Button" onserverclick="button1_click" runat=server ></FONT></form>
<script language=vb runat=server >
sub button1_click(sender as object,e as eventargs)
dim cna as ADOConnection=new ADOConnection
dim cma as ADOCommand=new ADOCommand
cna.provider="Microsoft.Jet.OLEDB.4.0"
cna.datasource="e:\asp学习\net\user.mdb"
cna.open()
cma.activeconnection=cna
cma.commandtype=commandtype.text
cma.commandtext=text1.value
cma.execute()
response.write ("影响了") & cma.recordsaffected & ("资料")
end sub
</script>
</body>
</HTML>
但当我执行程序时出现以下错误提示:
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误信息: BC30002: 未定义类型“ADOConnection”。
源错误:
行 18: <script language=vb runat=server >
行 19: sub button1_click(sender as object,e as eventargs)
行 20: dim cna as ADOConnection=new ADOConnection
行 21: dim cma as ADOCommand=new ADOCommand
行 22: cna.provider="Microsoft.Jet.OLEDB.4.0"
说我未定义类型:ADOConnection .这是怎么回事呀。我应该怎么样定义ADOConnection这个类型呀