在线等待,高手请进!
添加记录时,记录数始终不变(新记录可以添加进去,原有的记录自动删除一条)
在数据库中手动可以添加,请问题大概出现在哪里?
前面有个类似的程序可以添加,我在下面这个页面加入了个FIELDSET后,就出现了上述情况!
大致代码如下:
<%
set rsnews=server.CreateObject("adodb.recordset")
if Request.Form("pubnews")=1 then
sqlins="insert into ld_news(newstitle,newshref,filename,datetime,ispub) values ('"&Request.form("title")&"','"&Request.form("href")&"','"&Request.form("filename")&"','"&Request.Form("newsdate")&"','"&Request.form("ispub")&"')"
cn.execute sqlins
sql1="select max(newid), min(newid),count(*) from ld_news"
set rs=server.CreateObject("adodb.recordset")
rs.Open sql1,cn,3,1
if not rs.EOF then
if rs(2)>10 then
sqldel="delete from ld_news where newid='"&rs(1)&"'"
cn.execute sqldel
end if
end if
set rs=nothing
end if
%>
<%
if Request.Form("newsdel")=1 then
for i=1 to Request.Form("delsel").Count
sqldel="delete from ld_news where newid='"&Request.Form("delsel")(i)&"'"
cn.execute sqldel
next
end if
%>
<P align=center>
<form name=form2 method=post action="ld_news_list.asp">
<TABLE align=center width="75%" class="ResultTable" <%=ResultTableStyle(StyleIndex)%>>
<TR align=center class=ResultHead <%=ResultHeadStyle(StyleIndex)%>>
<td align=middle class=reporthead width=5%></TD>
<TD align=middle width="70%"class=reporthead nowrap><font class=BigFont>标题</font></TD>
<TD align=middle width="15%" class=reporthead nowrap><font class=BigFont>时间</font></TD>
<TD align=middle width="15%"class=reporthead nowrap><font class=BigFont>当前状态</font></TD>
</TR>
<%
newssql="select * from ld_news order by datetime desc"
rsnews.Open newssql,cn,3,1
rsnews.PageSize=6
dim curpage
curpage=Request.QueryString("curpage")
if isnull(curpage) or isempty(curpage) or curpage="" then
curpage=1
end if
rsnews.AbsolutePage=curpage
dim rowcount
rowcount=0
if rsnews.RecordCount>0 then
do while not rsnews.EOF and rowcount<rsnews.pagesize
%>
<TR >
<td align=middle ><input type="checkbox" name=delsel value="<%=rsnews("newid")%>"></TD>
<% if rsnews("newshref")<>"" then%>
<TD align=left ><a href="<%=rsnews("newshref")%>" target="_blank"><%=rsnews("newstitle")%></a></TD>
<% else %>
<TD align=left ><a href="../../ygdoc/<%=rsnews("filename")%>.asp" target="_blank"><%=rsnews("newstitle")%></a></TD>
<% end if %>
<TD align=center nowrap><%=rsnews("datetime")%></TD>
<TD align=center nowrap><% if rsnews("ispub")=1 then Response.Write"<font color=green>已发布" else Response.Write"<font color=red>未发布"%></TD>
</TR>
<%
rowcount=rowcount+1
rsnews.MoveNext
loop
end if
%>
<TR>
<TD align=middle vAlign=top nowrap class=ReportHead colspan=16>
总共[ <%=rsnews.RecordCount%> ]条记录
每页显示[ <%=rsnews.PageSize%> ]条记录
目前位第[ <%=curpage%>/<%=rsnews.PageCount%> ]页
<%if cint(curpage)=1 then%>
<A href="ld_news_list.asp?curpage=
<%curpage=cint(curpage)+1
Response.Write curpage
%>">下一页</A>
<% elseif cint(curpage)=rsnews.PageCount then%>
<A href="ld_news_list.asp?curpage=
<%curpage=cint(curpage)-1
Response.Write curpage
%>">上一页</A>
<% else%>
<A href="ld_news_list.asp?curpage=
<%curpage=Request.QueryString("curpage")
curpage=cint(curpage)-1
Response.Write curpage
%>">上一页</A>
<A href="ld_news_list.asp?curpage=
<%curpage=Request.QueryString("curpage")
if cint(curpage)<rsnews.PageCount then curpage=cint(curpage)+1
Response.Write curpage
%>">下一页</A>
<%end if%>
跳到第
<INPUT type="text" id=zdt name=zdt style="HEIGHT: 22px; WIDTH: 50px">
页
<INPUT type="button" value="Go!" id=zdb name=zdb LANGUAGE=javascript style="width:16pt;" class="StandardBtn" onclick="return zdb_onclick()">
</TD>
</TR>
<TR>
<TD align=middle colspan="5">
<input type="submit" name="delbtn" value="删 除" class="StandardBtn">
<input type="hidden" name="newsdel" value="1" >
</TD>
</TR>
</TABLE>
</form>
</P>
<%
set rsnews=nothing
%>
<p align="center">
<form name="form1" method="post" action="ld_news_list.asp">
<strong>发布综合新闻</strong>
<p align=center>
<input type="hidden" name=newsdate size=40>
<TABLE cellspacing="0" cellpadding="0" class=Report <%=stReportTable%> style="width:300px">
<TR>
<TD>标 题:</TD>
<TD><input type=text class="Text_Standard" name=title style=" WIDTH: 100%" ></TD>
</TR>
<TR>
<TD align="center" colspan="2" nowrap>
<input type="radio" checked value="0" id=button_addfj name=button_addfj LANGUAGE=javascript onclick="return button_addlj_onclick()"> 链接形式发布
<input type="radio" value="1" id=button_addfj name=button_addfj LANGUAGE=javascript onclick="return button_addfj_onclick()"> 文档形式发布
</TD>
</TR>
<TR>
<TD>链 接:</TD>
<TD nowrap><input type=text class="Text_Standard" name=href style=" WIDTH: 85%" ></TD>
</TR>
<TR>
<TD><input type=hidden class="Text_Standard" name=filename readonly style=" WIDTH: 100%" ></TD>
</TR>
<TR>
<TD>时 间:</TD>
<TD nowrap>
<SELECT id=q_year1 name=q_year1 style="width:70px">
<%for i=2000 to year(now())%>
<%if i=year(now()) then %>
<OPTION value="<%=i%>" selected><%=i%> </OPTION>
<%else%>
<OPTION value="<%=i%>"><%=i%> </OPTION>
<%end if%>
<%next%>
</SELECT>年 <SELECT id=q_month1 name=q_month1 style="width:50px">
<%for i=1 to 12%>
<%if i=month(now()) then %>
<OPTION value="<%=i%>" selected><%=i%> </OPTION>
<%else%>
<OPTION value="<%=i%>"><%=i%> </OPTION>
<%end if%>
<%next%>
</SELECT>月 <SELECT id=q_day1 name=q_day1 style="width:50px">
<%for i=1 to 31%>
<%if i=day(now()) then %>
<OPTION value="<%=i%>" selected><%=i%> </OPTION>
<%else%>
<OPTION value="<%=i%>"><%=i%> </OPTION>
<%end if%>
<%next%>
</SELECT>日</font></TD>
</tr>
<TR>
<TD>是否发布</TD>
<TD align=left ><select name="ispub" id="ispub">
<option value=1>是</option>
<option value=0>否</option>
</select>
</TD>
</tr>
<tr>
<TD align=middle colspan="2" >
<br>
<input type="button" class="OkBtn" name="pubbtn" >
<input type="hidden" value=1 name=pubnews>
<input type="button" class="CancelBtn" name="resetbtn" >
</td>
</tr>
</table>
<%
furl="ld_docadd.asp"
furl=furl+"?dwid="&cstr(dwid)
furl=furl+"&userid="&cstr(userid)
%>
<DIV>
<div id="addfile" name="addfile" style="display:none;">
<FIELDSET STYLE="width:78%;" align=center>
<LEGEND id="leg1" color=palegreen>文档发布设置</LEGEND>
<TABLE align=center width="90%" border=0 class=Report <%=stReportTable%>>
<TD vAlign=center align=right height="110px;">
<IFRAME id=mainframe name=mainframe frameborder=0 src="<%=furl%>" width="100%" height="100%"></IFRAME>
</TD>
</TR>
</TABLE>
</LEGEND>
</div>
<INPUT id="kmdwid" name="kmdwid" style="HEIGHT: 22px; WIDTH: 29px;display:none;" value="11">
<INPUT id="dwid" name="dwid" style="HEIGHT: 22px; WIDTH: 29px;display:none;" value="<%=dwid%>">
<INPUT id="userid" name="userid" style="HEIGHT: 22px; WIDTH: 28px;display:none;" value="<%=userid%>">
</DIV >
</form>