onlyonekgx你知道就说嘛,我这不正是在做入门书里的练习时碰到的问题嘛。
代码如下(Sample.aspx):
<%@Import Namespace=System.Data.ADO%>
<%@Import Namespace=System.Data%>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Sample.aspx.vb" Inherits="WebApplication3.Sample"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<Form Id="Form1" Runat="Server">
使用者账号: <Input type=text id="Text1" runat=server NAME="Text1"><br>
使用者密码: <Input type=text id="Text2" runat=server NAME="Text2"><br>
使用者姓名: <Input type=text id="Text3" runat=server NAME="Text3"><br>
使用者电话: <Input type=text id="Text4" runat=server NAME="Text4"><br>
使用者住址: <Input type=text id="Text5" runat=server NAME="Text5"><br>
E-Mail 信箱: <Input type=text id="Text6" runat=server NAME="Text6"><br>
<Button Id=Button1 Runat="Server"
OnServerClick="Button1_Click">确定
</Button>
</FORM>
<Span Id="Sp1" Runat="Server"/>
<Script Language="VB" Runat="Server">
Sub Button1_Click(Sender As Object, e As EventArgs)
Dim strConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" &
_
"Data Source=D:/manage.mdb"
Dim cmA As ADOCommand = New ADOCommand("",strConStr)
CmA.ActiveConnection.Open()
cmA.CommandText="Insert Into Members Values('" &
_
Text1.Value &
"','" &
Text2.Value &
"','" &
_
Text3.Value &
"','" &
Text4.Value &
"','" &
_
Text5.Value &
"','" &
Text6.Value &
"')"
cmA.Execute()
Sp1.InnerText="这个叙述影响了" &
cmA.RecordsAffected &
"笔资料"
End Sub
</SCRIPT>
</HTML>
运行后在IE中出现的错误页面如下:
Server Error in '/WebApplication3' 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 'ADOCommand' is not defined.
Source Error:
Line 20: Dim strConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" &
_
Line 21: "Data Source=D:/manage.mdb"
Line 22: Dim cmA As ADOCommand = New ADOCommand("",strConStr)
Line 23: CmA.ActiveConnection.Open()
Line 24: cmA.CommandText="Insert Into Members Values('" &
_
Source File: d:/inetpub/wwwroot/WebApplication3/Sample.aspx Line: 22
Show Detailed Compiler Output:
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET Version:1.1.4322.573