| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 834 人关注过本帖
标题:作业有错,帮忙指点一下
只看楼主 加入收藏
duoting
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-11-1
收藏
 问题点数:0 回复次数:2 
作业有错,帮忙指点一下
老师布置让我们做一个简单的注册页面和登陆页面。注册信息保存在数据库里。登陆页面进行校对。注册页面已经弄好了,但登陆页面除错了。麻烦指点一下。
<%@ 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
搜索更多相关主题的帖子: 作业 
2008-11-26 11:22
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
("select count(*) as total from users where user_name='"& user_name1.text &"' and password ='"& passwor1.text &"'", conn)

飘过~~
2008-11-26 11:48
C_B_Lu
Rank: 1
等 级:新手上路
威 望:1
帖 子:453
专家分:0
注 册:2006-1-10
收藏
得分:0 
Dim cmd As New OleDbCommand("select count(*) as total from users where user_name=user_name1.text and password =passwor1.text", conn)

这句代码应该有误吧..

帮助那些真正需要帮助的人,是对帮助你的人最好的回报!
2008-11-26 14:28
快速回复:作业有错,帮忙指点一下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017376 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved