标题:网站后台
只看楼主
zz550637
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-9-22
结帖率:0
已结贴  问题点数:0 回复次数:2 
网站后台
<%@language=vbscript codepage=936 %>
<!--#include file="../include/nAdminCheck.asp"-->
<%ConnPath="../../"%>
<!--#include file="../include/conn.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
dim Action,BigClassName,SmallClassName,rs,FoundErr,ErrMsg
Action=trim(Request("Action"))
BigClassID=trim(request("BigClassID"))
SmallClassName=trim(request("SmallClassName"))
SmallClassName_en=trim(request("SmallClassName_en"))
if Action="Add" then
    comment=Request("comment")
    nImg=trim(request("nImg"))
    if BigClassID="" then
        FoundErr=True
        ErrMsg=ErrMsg & "<br><li>请先选择大栏目名称!</li>"
    end if
    if SmallClassName="" then
        FoundErr=True
        ErrMsg=ErrMsg & "<br><li>文章子栏目名不能为空!</li>"
    end if
    if FoundErr<>True then
        Set rs=Server.CreateObject("Adodb.RecordSet")
        rs.open "Select * From pnClass Where Class_ID="&Cint(BigClassID)&" AND nClass_Name='" & SmallClassName & "'",conn,1,3
        if not rs.EOF then
            FoundErr=True
            ErrMsg=ErrMsg & "<br><li>该大栏目中已经存在子栏目“" & SmallClassName & "”!</li>"
        else
             rs.addnew
            rs("Class_ID")=BigClassID
             rs("nClass_Name")=SmallClassName
            rs("nClass_Name_en")=SmallClassName_en
            rs("nImg")=cImg
             rs("comment")=comment
                rs.update
             rs.Close
             set rs=Nothing
             call CloseConn()
            Response.Redirect "ClassManage.asp"  
        end if
    end if
end if
if FoundErr=True then
    call WriteErrMsg()
else
%>
<script language="JavaScript" type="text/JavaScript">
function checkSmall()
{
  if (document.form2.BigClassID.value=="")
  {
    alert("请先选择大栏目名称!");
    document.form2.BigClassID.focus();
    return false;
  }

  if (document.form2.SmallClassName.value=="")
  {
    alert("子栏目中文名称不能为空!");
    document.form2.SmallClassName.focus();
    return false;
  }
    if (document.form2.SmallClassName_en.value=="")
  {
    alert("子栏目英文名称不能为空!");
    document.form2.SmallClassName_en.focus();
    return false;
  }
}
</script>
<link href="../include/sys.css" rel="stylesheet" type="text/css">
<div align="center">
    <p>&nbsp;</p>
    <p><a href="classmanage.asp" class="white"><strong>栏 目 设 置</strong></a>
        <br>
  </p>
</div>
<table width="452" border="0" align="center" cellpadding="3" cellspacing="1" class="TABLEresult">
  <form name="form2" method="post" action="ClassAddSmall.asp" onsubmit="return checkSmall()">
          <tr bgcolor="#999999" class="title">
            <td height="25" colspan="2" align="center" background="../include/sys.gif"><strong class="head">添加子栏目</strong></td>
          </tr>
          <tr class="tdbg">
            <td width="113" height="22" align="center" bgcolor="#C0C0C0"><strong class="jingfont">所属大栏目:</strong></td>
            <td width="324" bgcolor="#E3E3E3"> <select name="BigClassID" class="textinput">
                <%
    dim rsBigClass
    set rsBigClass=server.CreateObject("adodb.recordset")
    rsBigClass.open "Select * From pClass",conn,1,1
    if rsBigClass.bof and rsBigClass.bof then
        response.write "<option>请先添加大栏目</option>"
    else
        do while not rsBigClass.eof
            if rsBigClass("Class_ID")=Cint(BigClassID) then
                response.write "<option value='"& rsBigClass("Class_ID") & "' selected>" & rsBigClass("Class_Name") & "</option>"
            else
                response.write "<option value='"& rsBigClass("Class_ID") & "'>" & rsBigClass("Class_Name") & "</option>"
            end if
            rsBigClass.movenext
        loop
    end if
    rsBigClass.close
    set rsBigClass=nothing
    %>
              </select></td>
          </tr>
          <tr class="tdbg">
            <td width="113" height="22" align="center" bgcolor="#C0C0C0"><strong>子栏目中文名称:</strong></td>
            <td bgcolor="#E3E3E3"> <input name="SmallClassName" type="text" class="textinput" size="20" maxlength="30"></td>
          </tr>
          <tr class="tdbg">
            <td width="113" height="11" align="center" bgcolor="#C0C0C0"><strong>子栏目英文名称:</strong></td>
            <td bgcolor="#E3E3E3"><input name="SmallClassName_en" type="text" class="textinput" id="SmallClassName_en" size="20" maxlength="30" /></td>
          </tr>
        <tr bgcolor="#E3E3E3" class="tdbg">
            <td width="113" height="22" bgcolor="#C0C0C0">
                <div align="right" class="font"><strong>栏目图片:</strong></div>            </td>
            <td width="324" bgcolor="#E3E3E3">
                <input name="nImg" type="text" class="textinput" id="nImg" size="30" maxlength="50">
                &nbsp;<input class="textbotton1" type="button" name="up_pic" value="小图片上传" onClick="window.open('../Up_Pic.asp?formname=form1&editname=nImg&uppath=../uploadfile&filelx=pic','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')">            </td>
        </tr>
        <tr bgcolor="#E3E3E3" class="tdbg">
            <td width="113" height="22" bgcolor="#C0C0C0">
                <div align="right" class="font"><strong>栏目介绍:</strong></div>            </td>
            <td width="324" bgcolor="#E3E3E3"><textarea name="comment" cols="40" rows="5" class="textarea" id="comment"></textarea>            </td>
        </tr>
          <tr class="tdbg">
            <td height="22" align="center" bgcolor="#C0C0C0">&nbsp; </td>
            <td height="22" align="center" bgcolor="#E3E3E3"> <div align="left">
                <input name="Action" type="hidden" id="Action" value="Add">
                <input name="Add" type="submit" class="textbotton1" value=" 添 加 ">
              </div></td>
          </tr>
  </form>
</table>
<%
end if
%>
 



系统提示:Microsoft JET Database Engine 错误 '80040e21'

由于将在索引、 主关键字、或关系中创建重复的值,请求对表的改变没有成功。 改变该字段中的或包含重复数据的字段中的数据,删除索引或重新定义索引以允许重复的值并再试一次。

/back/admin/Products/ClassAddSmall.asp,行 36
搜索更多相关主题的帖子: language 网站 Request request content 
2011-09-22 14:10
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:10 
这个错误表明,你在往不允许数据重复的字段里添加重复数据。
             rs.addnew
            rs("Class_ID")=BigClassID
             rs("nClass_Name")=SmallClassName
            rs("nClass_Name_en")=SmallClassName_en
            rs("nImg")=cImg
             rs("comment")=comment
                rs.update
             rs.Close
这是最有可能出错的代码,红字是最有可能出错的字段。

[ 本帖最后由 yms123 于 2011-9-23 11:28 编辑 ]
2011-09-23 11:26
zhangyao3287
Rank: 2
来 自:黑龙江省
等 级:论坛游民
威 望:2
帖 子:173
专家分:51
注 册:2008-5-25
得分:10 
Class_ID是不是自动编号?
2011-09-24 10:14



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-350586-1-1.html




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

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