作业有错,帮忙指点一下
老师布置让我们做一个简单的注册页面和登陆页面。注册信息保存在数据库里。登陆页面进行校对。注册页面已经弄好了,但登陆页面除错了。麻烦指点一下。<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("userinfo1.mdb"))
Dim cmd As New OleDbCommand("select count(*) as total from users where user_name=user_name1.text and password =passwor1.text", conn)
conn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader()
Dim total1 = dr.Item("total")
conn.Close()
If total1 Then
message.Text = "欢迎光临"
Else
message.Text = "用户名或密码出错"
End If
End Sub
</script>
<html>
<body>
<h4 align="center">登录页面</h4>
<center>
<form id="Form1" runat="server">
<table border="1" width="80%" cellpading="2" cellspacing="0">
<tr>
<td style="height: 28px">用户名:</td>
<td style="height: 28px"><asp:Textbox id="user_name1" runat="server"/></td>
</tr>
<tr>
<td style="height: 30px">密码:</td>
<td style="height: 30px"><asp:Textbox id="password1" textmode="Password" runat="server" Width="155px"/></td>
</tr>
<tr>
<td style="height: 28px"><asp:Button ID="Button1" runat="server" Text="确定" OnClick="Button1_Click" /></td></tr>
<td style="height: 28px"><asp:Label id="message" runat="server"/></td>
</table>
</form>
</center>
</body>
</html>
运行填好信息提交时出现如下错误:
至少一个参数没有被指定值。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[OleDbException (0x80040e10): 至少一个参数没有被指定值。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +177
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +56
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +105
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +92
System.Data.OleDb.OleDbCommand.ExecuteReader() +6
ASP.default3_aspx.Button1_Click(Object sender, EventArgs e) +111
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921