好奇怪的问题?

y121311 2008-03-31 11:38:31
在ASP与SQL的查询里,数据库明明只有一条记录。但却查出了两条一模一样的记录。晕了。怎么回事。当新增加记录时,查出来的却正常,即没有重复显示两样一表 记录。之前的数据记录怎么就会出现两条一样的显示呢。。真是奇怪。要如何解决?请高手明示,,在下感激不尽!
...全文
75 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
y121311 2008-04-02
原来的代码太长了。所以被我删除了部分,将一些不关紧要的代码删除了。原来的代码
<%set rs=server.createobject("adodb.recordset")
if leixing="big" then%>
<%rs.open "select * from computer where anclassid="&anclassid&" order by adddate desc",conn,1,1
elseif leixing="small" then%>
<%rs.open "select * from computer where anclassid="&anclassid&" and nclassid="&nclassid&" order by adddate desc",conn,1,1

else
dim px '用户自定义排序信息!
px=request.QueryString("px")
if px="" then
rs.open "select * from computer order by adddate desc",conn,1,1
else
select case px
'
case "1"
rs.open "select * from computer order by adddate asc",conn,1,1
case "2"
rs.open "select * from computer order by updatedate desc",conn,1,1

end select
end if
end if
if rs.recordcount=0 then
%>
<table width="370" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td align=center>暂无PC或设备</td>
</tr>
</table>
<% dim iCount,iPageSize,maxpage,page,x,action '分页开始
else
rs.PageSize =10 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount
page=request("page")

if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if

if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if

rs.AbsolutePage=Page

if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
'x=rs.recordcount
For i=1 To x%>
<!--#include file="shangping.asp"-->
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="1" bgcolor="#CCCCCC"><img src="images/dot_03.gif" width="9" height="1" border="0"></td>
</tr>
</table>
<%rs.movenext
i=i+1
next
call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
end if
rs.close
set rs=nothing
Sub PageControl(iCount,pagecount,page,table_style,font_style)
'生成上一页下一页链接
Dim query, a, x, temp
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")

query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next
Response.Write("<table " & Table_style & ">" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR>" & vbCrLf )
Response.Write("<TD align=right>" & vbCrLf )
Response.Write(font_style & vbCrLf )

if page<=1 then
Response.Write ("首页 " & vbCrLf)
Response.Write ("上页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=1>首页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page-1) & ">上页</A> " & vbCrLf)
end if

if page>=pagecount then
Response.Write ("下页 " & vbCrLf)
Response.Write ("尾页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page+1) & ">下页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & ">尾页</A> " & vbCrLf)
end if

Response.Write(" 页次:" & page & "/" & pageCount & "页" & vbCrLf)
Response.Write(" 共有" & iCount & "条记录" & vbCrLf)
Response.Write(" 转到" & "<INPUT TYEP=TEXT NAME=page SIZE=1 Maxlength=5 VALUE=" & page & ">" & "页" & vbCrLf & "<INPUT type=submit style=""font-size: 9pt"" value=GO class=b2>")
Response.Write("</TD>" & vbCrLf )
Response.Write("</TR></form>" & vbCrLf )
Response.Write("</table>" & vbCrLf )
End Sub
%>
</table>
回复
gingerkang 2008-04-02
if rs.recordcount=0 then
response.write"暂无PC或设备"
else
dim iCount,iPageSize,maxpage,page,x,action '分页开始
else

这段怎么看都不能正常运行的吧,没有报错吗?
回复
y121311 2008-04-02
用查询分析器查出来的是一条记录。更改了所有记录的日期,再查询时问题依旧。晕了,查询语句里没有时间条件呀,怎么网页就显示两条一模一样的,是否SQL里有触发器在搞怪!
回复
y121311 2008-04-02
拜读了各位的意见。我还是将代码贴出来吧。
<%set rs=server.createobject("adodb.recordset")
if leixing="big" then%>
<%rs.open "select * from computer where anclassid="&anclassid&" order by adddate desc",conn,1,1
elseif leixing="small" then%>
<%rs.open "select * from computer where anclassid="&anclassid&" and nclassid="&nclassid&" order by adddate desc",conn,1,1

else
dim px '用户自定义排序信息!
px=request.QueryString("px")
if px="" then
rs.open "select * from computer order by adddate desc",conn,1,1
else
select case px
'
case "1"
rs.open "select * from computer order by adddate asc",conn,1,1
case "2"
rs.open "select * from computer order by updatedate desc",conn,1,1

end select
end if
end if
if rs.recordcount=0 then
response.write"暂无PC或设备"
else
dim iCount,iPageSize,maxpage,page,x,action '分页开始
else
rs.PageSize =10 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount
page=request("page")

if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if

if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if

rs.AbsolutePage=Page

if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
For i=1 To x%>
<!--#include file="viewpc.asp"-->
<%rs.movenext
i=i+1
next
end if
rs.close
set rs=nothing
%>
viewpc.asp文件代码如下:
<table width="100%" border="0" cellspacing="0" cellpadding="2" align="center" class="table-xia">
<tr>
<td width="22%">
<div align="center"><img src="<%=trim(rs("bookpic"))%>" width=111 border=0 height="110"></div> </td>
<td width="78%"><table width="622" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#E8F1FF">
<tr>
<td width="72"><%=trim(rs("tp"))%></td>
<td width="111"><%=trim(rs("bookpic"))%></td>
<td width="136">创建人:<%=trim(rs("tjr"))%></td>
<td width="111">加入时间:<%=trim(rs("adddate"))%></td>
</tr>
<tr>
<td colspan="4"><%if rs("cpu")<>"" then%><table width="500" border="0" align="left" cellspacing="1" bgcolor="#6B8FC8">
<tr bgcolor="#E8F1FF">
<td width="186" rowspan="2"><%=trim(rs("ml"))%></td>
<td align="center">CPU</td>
</tr>
<tr bgcolor="#E8F1FF">
<td width="307"><%=trim(rs("cpu"))%></td>
</tr>
</table><%else
response.write "没有配置说明"
end if%></td>
</tr>
</table></td>
</tr>
</table>
回复
itzhiren 2008-03-31
代码贴出来
回复
wpjwll 2008-03-31
把代码贴出来
回复
niansen 2008-03-31
把代码贴出来看下啊,不然怎么找出原因列!!
回复
小逗狗 2008-03-31
你查询时的输出语句有没有问题,检查一下吧
回复
braveboy 2008-03-31
查询语句拿出来晾下
回复
mxbzz2008 2008-03-31
就是··LZ会不会求助啊?
回复
heshengfen123 2008-03-31
不知道,看过才知
回复
-晴天 2008-03-31
可能的情况:
1.你的数据库里本来就是两条,你在客户端没刷新,自以为是一条.
2.你的程序里设置了有条件的循环,在某个日期时间之前的记录循环写了一下,所以看上去丙条了.
3.你的程序里设置了条件语句,在某个日期时间之间之间的记录要输出,但你的条件语句没写 else 而只写了 end if 了,所以后面又给输出了一次.
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-03-31 11:38
社区公告
暂无公告