首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

急批改ASP文章内容时,当提交的时候,却变成了添加一条记录!请大家指教

2012-09-10 
急!修改ASP文章内容时,当提交的时候,却变成了添加一条记录!请大家指教!--#include fileconn.asp--!-

急!修改ASP文章内容时,当提交的时候,却变成了添加一条记录!请大家指教
<!--#include file="conn.asp"-->
<!--#include file="admin.asp"-->

<%
title=server.htmlencode(Trim(Request("id")))
Content=Trim(Request("Content"))
BigClassName=request("BigClassName")
client=request("client")
prosize=request("prosize")
prodic=request("prodic")
compyear=request("compyear")
SmallClassName=request("SmallClassName")
%>
<%if Request.QueryString("mark")="southidc" then%>
<%
If Content="" Then
response.write "SORRY <br>"
response.write "内容不能为空!!<a href=""javascript:history.go(-1)"">返回重输</a>"
response.end
end if

Set rs = Server.CreateObject("ADODB.Recordset")
if title="" then
sql="select * from Procase"
else
sql="select * from Procase where id="&title
end if
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
response.Write(title)
if title="" then
rs.addnew
else
end if
rs("SmallClassName")=SmallClassName
rs("BigClassName")=BigClassName
rs("title")=request.Form("arttitle")
rs("Content")=Content
rs("client")=client
rs("prosize")=prosize
rs("compyear")=compyear
rs("prodic")=prodic
rs("firstImageName")= trim(Request.form("img"))
rs.update
rs.close
response.redirect "News_Manage.asp"
end if
%>
<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from SmallClass_New order by SmallClassID asc"
rs.open sql,conn,1,1
%>
<script language = "JavaScript">
var onecount;
subcat = new Array();
  <%
  count = 0
  do while not rs.eof 
  %>
subcat[<%=count%>] = new Array("<%= trim(rs("SmallClassName"))%>","<%= trim(rs("BigClassName"))%>","<%= trim(rs("SmallClassName"))%>");
   
<%
  count = count + 1
  rs.movenext
  loop
  rs.close
  %>


onecount=<%=count%>;

function changelocation(locationid)
  {
  document.myform.SmallClassName.length = 1; 
  var locationid=locationid;
  var i;
  for (i=0;i < onecount; i++)
  {
  if (subcat[i][1] == locationid)
  { 
  document.myform.SmallClassName.options[document.myform.SmallClassName.length] = new Option(subcat[i][0], subcat[i][2]);
  }  
  }
  }  
function CheckForm()
{
  if (editor.EditMode.checked==true)
document.myform.Content.value=editor.HtmlEdit.document.body.innerText;
  else
document.myform.Content.value=editor.HtmlEdit.document.body.innerHTML; 
 
  if (document.myform.Content.value=="")
  {
  alert("内容不能为空!");
editor.HtmlEdit.focus();
return false;
  }
  return true;  
}
</script>
<%
mainContent=""
Set rs1 = Server.CreateObject("ADODB.Recordset")
sql1="select * from Procase where id="&title
Set rs1= Server.CreateObject("ADODB.Recordset")
rs1.open sql1,conn,1,3
if rs1.bof and rs1.eof then


else
mainContent = rs1("Content")
end if
%>
<!-- #include file="Inc/Head.asp" -->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
  <td align="center" valign="top"> <br> <br> <table width="790" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCFFFF" class="table_southidc"><form method="post" name="myform" action="ArtModify.asp?mark=southidc&ArticleID=<%=Request("ArticleID")%>" onSubmit="return CheckForm();">

  <tr> 
  <td width="159" height="12" align="right" class="back_southidc">标题:</td>
  <td width="620" class="back_southidc"><input name="arttitle" value="<%=rs1("title")%>" size="50" /></td>
  </tr>
 <tr> 
  <td height="0" align="right"><font color="#FF0000">*</font>类别:</td>
  <td valign="top"> 
  <%
  sql = "select * from BigClass_New"
  rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
else
%> <select name="BigClassName" onChange="changelocation(document.myform.BigClassName.options[document.myform.BigClassName.selectedIndex].value)" size="1">
  <%
do while not rs.eof
%>
  <option value="<%=trim(rs("BigClassName"))%>" selected <% if rs("BigClassName")=rs1("BigClassName") then response.Write("selected") end if%>><%=trim(rs("BigClassName"))%></option>
  <%
rs.movenext
  loop
end if
  rs.close
%>
  </select> <select name="SmallClassName">
  <option value="" selected <%if rso("SmallClassName")="" then response.write "selected"%>>不指定小类</option>
  <%
sql="select * from SmallClass_New where BigClassName='" & rs1("BigClassName") & "'" 
rs.open sql,conn,1,1 
if not(rs.eof and rs.bof) then  
do while not rs.eof %>
  <option value="<%=rs("SmallClassName")%>" <% if rs("SmallClassName")=rs1("SmallClassName") then response.Write("selected") end if%>><%=rs("SmallClassName")%></option>
  <%
rs.movenext
loop
end if
rs.close
%>
  </select> 





</td>
  </tr>
  <tr> 
  <td colspan="2"><div align="center"> 
  <table width="100%" border="0" cellspacing="1" cellpadding="0">
   
  <tr>
  <td width="20%" height="22" align="right" valign="top"><textarea name="Content" style="display:none"><%=mainContent%></textarea>


  内容:</td>
  <td width="80%" align="center">
<iframe id="editor" src="../ArtMagEditor.asp?mytitle=<%=Request("id")%>" frameborder=1 scrolling=no width="620" height="405"></iframe></td>
  </tr>
  <tr bgcolor="#ECF5FF"> 
  <td height="12">图片地址:</td>
  <td><input name="img" type="text" id="img" value="<%=rs1("FirstImageName")%>" size="30" maxlength="50">
  <br />
  <iframe style="top:2px" ID="UploadFiles" src="../upload_Photo.asp?PhotoUrlID=5" frameborder=0 scrolling=no width="300" height="25"></iframe></td>
  </tr>
   
  <tr> 
  <td height="25" colspan="2"> 
  <div align="center"> 
  <input name="submit" type="submit" value="确定">
  &nbsp; 
  <input name="reset" type="reset" value="取消">

  </div></td>
  </tr>
  </table>
  </div></td>
  </tr> </form>
  </table>
  <br> </td>
  </tr>
</table>
<%rs1.close%>
<!-- #include file="Inc/Foot.asp" -->

[解决办法]
你的问题就出现在缺少id的标签:<input type="hidden" name="id" value="<%=Rs("id")%>" /> 把它加到form标签内即可
[解决办法]
大姐看看上面的回复吧,已经提醒你少了 input name=id
[解决办法]
title=server.htmlencode(Trim(Request("id")))
你注意看你的哲理
你的title是经过这个参数ID才得到值的
所以,ID如果没有值,那么title没有值
那么你下面的
if title="" then
rs.addnew
else
end if

哲理的title永远都执行第一句,也就是永远执行rs.addnew这个了
所以你要保证id有值,才能保证title有值,才能区分增加和修改

热点排行