| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 562 人关注过本帖
标题:网页出错,麻烦高手指点一下
只看楼主 加入收藏
duoting
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-11-1
收藏
 问题点数:0 回复次数:4 
网页出错,麻烦高手指点一下
老师让我们做一个注册网页,用到数据库,页面显示正确,但点击提交时出错。
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
    Sub Enter_Click(ByVal ByValSender As Object, ByVal E As EventArgs)
        Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("userinfo.mdb"))
        Dim strSql As String
        strSql = "Insert Into users(user_name,password,real_name,tel_number,email) Values('" & user_name1.Text & "','" & password1.Text & "','" & real_name1.Text & "'," & tel_number1.Text & "','" & email1.Text & "')"
        Dim cmd As New OleDbCommand(strSql, conn)
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()
        message.Text = "谢谢注册"
    End Sub
</script>
<html>
<body>
    <h4 align="center">注册页面</h4>
    <center>
    <form id="Form1" runat="server">
    <table>
        <tr>
            <td>用户名:</td>
            <td><asp:Textbox id="user_name1" runat="server"/></td>
        </tr>
        <tr>
            <td>密码:</td>
            <td><asp:Textbox id="password1" textmode="Password"  runat="server"/></td>
        </tr>
        <tr>
            <td>真实姓名:</td>
            <td><asp:Textbox id="real_name1"  columns="40" rows="4" runat="server"/></td>
        </tr>
        <tr>
            <td>电话号码:</td>
            <td><asp:Textbox id="tel_number1"  columns="40" rows="4" runat="server"/>                
            </td>
            <td>电子邮箱:</td>
            <td><asp:Textbox id="email1"  runat="server"/>                
            </td>
        </tr>
        <tr>
            <td></td>
            <td><asp:button id="Enter" Text=" 提 交 " onClick="Enter_Click" runat="server"/></td>
        </tr>
    </table>
    <asp:Label id="message" runat="server"/>
    </form>
    </center>
</body>
</html>
搜索更多相关主题的帖子: 新手求教 
2008-11-25 22:49
hebingbing
Rank: 6Rank: 6
来 自:黄土高坡
等 级:贵宾
威 望:27
帖 子:3417
专家分:371
注 册:2007-10-22
收藏
得分:0 
请问出现什么错误啊……
2008-11-25 22:53
duoting
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-11-1
收藏
得分:0 
显示如下


Server Error in '/实验九' Application.
--------------------------------------------------------------------------------

INSERT INTO 语句的语法错误。
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: INSERT INTO 语句的语法错误。

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 (0x80040e14): INSERT INTO 语句的语法错误。]
   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.ExecuteNonQuery() +89
   ASP.default2_aspx.Enter_Click(Object ByValSender, EventArgs E) +403
   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-25 22:54
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
INSERT INTO 语句的语法错误。

strSql = "Insert Into users(user_name,password,real_name,tel_number,email) Values('" & user_name1.Text & "','" & password1.Text & "','" & real_name1.Text & "'," & tel_number1.Text & "','" & email1.Text & "')"

====>

strSql = "Insert Into users(user_name,password,real_name,tel_number,email) Values('" & user_name1.Text & "','" & password1.Text & "','" & real_name1.Text & "','" & tel_number1.Text & "','" & email1.Text & "')"


少了一个单引号

飘过~~
2008-11-26 09:29
duoting
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-11-1
收藏
得分:0 
好了,太感谢了。
2008-11-26 10:26
快速回复:网页出错,麻烦高手指点一下
数据加载中...
 
   



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

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