| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 565 人关注过本帖
标题:急 ASP 留言板提交时出错
只看楼主 加入收藏
gq198718
Rank: 4
等 级:业余侠客
威 望:1
帖 子:86
专家分:200
注 册:2010-6-6
结帖率:100%
收藏
 问题点数:0 回复次数:3 
急 ASP 留言板提交时出错
HTTP 错误 500.100 - 内部服务器错误 - ASP 错误
Internet 信息服务
错误类型:
Microsoft JET Database Engine (0x80040E07)
标准表达式中数据类型不匹配。
/liuyanban.asp, 第 81 行
第81行代码是: MM_editCmd.Execute();
源代码:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/conn.asp" -->
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
  MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}

// boolean to abort record edit
var MM_abortEdit = false;

// query string to execute
var MM_editQuery = "";
%>
<%
// *** Insert Record: set variables

if (String(Request("MM_insert")) == "form1") {

  var MM_editConnection = MM_conn_STRING;
  var MM_editTable  = "t_message";
  var MM_editRedirectUrl = "liuyan.asp";
  var MM_fieldsStr = "t_name|value|t_message|value|t_time|value";
  var MM_columnsStr = "t_name|',none,''|t_message|',none,''|t_time|',none,NULL";

  // create the MM_fields and MM_columns arrays
  var MM_fields = MM_fieldsStr.split("|");
  var MM_columns = MM_columnsStr.split("|");
  
  // set the form values
  for (var i=0; i+1 < MM_fields.length; i+=2) {
    MM_fields[i+1] = String(Request.Form(MM_fields[i]));
  }

  // append the query string to the redirect URL
  if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
    MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
  }
}
%>
<%
// *** Insert Record: construct a sql insert statement and execute it

if (String(Request("MM_insert")) != "undefined") {

  // create the sql insert statement
  var MM_tableValues = "", MM_dbValues = "";
  for (var i=0; i+1 < MM_fields.length; i+=2) {
    var formVal = MM_fields[i+1];
    var MM_typesArray = MM_columns[i+1].split(",");
    var delim =    (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
    var altVal =   (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
    var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
    if (formVal == "" || formVal == "undefined") {
      formVal = emptyVal;
    } else {
      if (altVal != "") {
        formVal = altVal;
      } else if (delim == "'") { // escape quotes
        formVal = "'" + formVal.replace(/'/g,"''") + "'";
      } else {
        formVal = delim + formVal + delim;
      }
    }
    MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
    MM_dbValues += ((i != 0) ? "," : "") + formVal;
  }
  MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";

  if (!MM_abortEdit) {
    // execute the insert
    var MM_editCmd = Server.CreateObject('');
    //response.write MM_editQuery;


    MM_editCmd.ActiveConnection = MM_editConnection;
    MM_ = MM_editQuery;
    MM_editCmd.Execute();
    MM_editCmd.ActiveConnection.Close();

    if (MM_editRedirectUrl) {
      Response.Redirect(MM_editRedirectUrl);
    }
  }

}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>欢迎光临</title>
</head>

<body>
<form method="post" action="<%=MM_editAction%>" name="form1">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">留言人:</td>
      <td><input type="text" name="t_name" value="" size="32">
      </td>
    </tr>
    <tr>
      <td nowrap align="right" valign="top">留言内容:</td>
      <td valign="baseline"><textarea name="t_message" cols="50" rows="5"></textarea>
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="插入记录">
      </td>
    </tr>
  </table>
  <input type="hidden" name="t_time" value="<"%=now()%">
  
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</body>
</html>
搜索更多相关主题的帖子: 留言 ASP 
2010-06-07 07:42
yifan2727
Rank: 1
等 级:新手上路
帖 子:2
专家分:5
注 册:2010-4-17
收藏
得分:0 
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DDcn;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string Lnm = this.TextBox1.Text.ToString();
        string Lzt = this.TextBox2.Text.ToString();
        string Lnr = this.TextBox3.Text.ToString();
        string cn = new Dcn().Dcnstring().ToString();
        //chat.InnerHtml = Application["show"].ToString();
      //string cn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath("~/App_Data/y1.mdb");
      OleDbConnection DBcn = new OleDbConnection(cn);
      string tm = DateTime.Now.ToString();
      OleDbCommand cmd = new OleDbCommand("Insert INTO Y2(作者,主题,内容,时间) VALUES('" + Lnm + "','" + Lzt + "','" + Lnr + "','" + tm + "')", DBcn);
      try
      {
          DBcn.Open();
          cmd.ExecuteNonQuery();
      }
      catch
      {
          //throw;
          chat.InnerHtml = Application["show"].ToString();
      }
      finally
      {
          DBcn.Close();

      }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
    }
}


<body bgcolor="#ccccff">
    <form id="form1" runat="server">
    <div id=chat runat =server>
        <br />
        <br />
        <br />
        <table style="width: 400px; height: 24px; text-align: center; border-right: #0099ff 1px solid; border-top: #0099ff 1px solid; border-left: #0099ff 1px solid; border-bottom: #0099ff 1px solid;" align=center cellspacing="0">
            <tr>
                <td colspan="2" style="background-image: url(ig/4.jpg); height: 236px">
                </td>
            </tr>
            <tr>
                <td style="width: 142px; height: 24px"  >
                    <asp:Label ID="Label1" runat="server" Text="作者"></asp:Label></td>
                <td style="width: 210px; height: 24px" >
                    <asp:TextBox ID="TextBox1" runat="server" Width="192px"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 142px; height: 24px"  >
                    <asp:Label ID="Label2" runat="server" Text="主题 "></asp:Label></td>
                <td style="width: 210px; height: 24px" >
                    <asp:TextBox ID="TextBox2" runat="server" Width="192px"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 142px; height: 106px"  >
                    <asp:Label ID="Label3" runat="server" Text="内容 "></asp:Label></td>
                <td style="width: 210px; height: 106px" >
                    <asp:TextBox ID="TextBox3" runat="server" Height="88px" TextMode="MultiLine" Width="208px"></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan="2" style="height: 1px">
                    <asp:Button ID="Button1" runat="server" Text="确定" OnClick="Button1_Click" />
                    <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="取消" /></td>
            </tr>
            <tr>
                <td colspan="2" style="height: 61px">
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" CellPadding="4" DataKeyNames="编号" DataSourceID="AccessDataSource1"
            ForeColor="#333333" GridLines="None" Height="216px" Width="592px">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                <asp:BoundField DataField="编号" HeaderText="编号" InsertVisible="False" ReadOnly="True"
                    SortExpression="编号" />
                <asp:BoundField DataField="作者" HeaderText="作者" SortExpression="作者" />
                <asp:BoundField DataField="主题" HeaderText="主题" SortExpression="主题" />
                <asp:BoundField DataField="内容" HeaderText="内容" SortExpression="内容" />
                <asp:BoundField DataField="时间" HeaderText="时间" SortExpression="时间" />
                <asp:BoundField DataField="IP" HeaderText="IP" SortExpression="IP" />
            </Columns>
            <SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
            <RowStyle BackColor="#EFF3FB" />
            <EditRowStyle BackColor="#2461BF" />
        </asp:GridView>
        <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/y1.mdb"
            DeleteCommand="DELETE FROM [Y2] WHERE [编号] = ?" InsertCommand="INSERT INTO [Y2] ([编号], [作者], [主题], [内容], [时间], [IP]) VALUES (?, ?, ?, ?, ?, ?)"
            SelectCommand="SELECT * FROM [Y2]" UpdateCommand="UPDATE [Y2] SET [作者] = ?, [主题] = ?, [内容] = ?, [时间] = ?, [IP] = ? WHERE [编号] = ?">
            <DeleteParameters>
                <asp:Parameter Name="编号" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="作者" Type="String" />
                <asp:Parameter Name="主题" Type="String" />
                <asp:Parameter Name="内容" Type="String" />
                <asp:Parameter Name="时间" Type="DateTime" />
                <asp:Parameter Name="IP" Type="String" />
                <asp:Parameter Name="编号" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="编号" Type="Int32" />
                <asp:Parameter Name="作者" Type="String" />
                <asp:Parameter Name="主题" Type="String" />
                <asp:Parameter Name="内容" Type="String" />
                <asp:Parameter Name="时间" Type="DateTime" />
                <asp:Parameter Name="IP" Type="String" />
            </InsertParameters>
        </asp:AccessDataSource>
                </td>
            </tr>
        </table>
        &nbsp;
        <br />
   
    </div>
    </form>
</body>
这是我以前用过的,可供参考
2010-06-07 09:30
gq198718
Rank: 4
等 级:业余侠客
威 望:1
帖 子:86
专家分:200
注 册:2010-6-6
收藏
得分:0 
谢谢啊
2010-06-07 09:48
gq198718
Rank: 4
等 级:业余侠客
威 望:1
帖 子:86
专家分:200
注 册:2010-6-6
收藏
得分:0 
这个问题是我重装系统以后出现的,
2010-06-07 09:50
快速回复:急 ASP 留言板提交时出错
数据加载中...
 
   



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

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