提取数据出错,该如何处理呢?

xuallen 2003-12-23 04:40:08
我从数据库中按照如下语句选择记录,
sqlTS1="select * from tblReports where Sections='TS' and ReportMonth='"& ReportMonth &"' and ReportWeek='Week1'"
Set rsts1=conn.execute (sqlTS1)
但是当记录中没有"Week1"时总出现错误页面,
如何当没有匹配字符时就显示空记录呀?
...全文
136 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xeimm 2003-12-23
  • 打赏
  • 举报
回复
if rsts1.bof and rsts1.eof then
response.write("none")
else
.... '输出数据
end if
monkeys 2003-12-23
  • 打赏
  • 举报
回复
sqlTS1="select * from tblReports where Sections='TS' and ReportMonth='"& ReportMonth &"' and ReportWeek='Week1'"

Set rsts1=conn.execute (sqlTS1)

if rsts1.eof or rsts1.bof then
Response.write("很抱歉,没有你所要查询的信息")
else
输出你的记录
end if
aoenzh 2003-12-23
  • 打赏
  • 举报
回复
在数据提交前,先判断是不是空。
reaperwu 2003-12-23
  • 打赏
  • 举报
回复
if rstsl.RecordCount = 0 then
'Response.Write "没有记录"
else
'输出记录
end if
linzhifeng 2003-12-23
  • 打赏
  • 举报
回复
if rstsl.eof and rstsl.bof then
...
end if

swich 2003-12-23
  • 打赏
  • 举报
回复
if rsts1.eof or rsts1.bof then
....
else
....
end if
bzscs 2003-12-23
  • 打赏
  • 举报
回复
if rsts1.bof and rsts1.eof then
response.write("none")
else
.... '输出数据
end if
我通常这样
sxsgssgs 2003-12-23
  • 打赏
  • 举报
回复
set rs=server.createobject("adodb.recordset")
sqlTS1="select * from tblReports where Sections='TS' and ReportMonth='"& ReportMonth &"' and ReportWeek='Week1'"
rs.open sqlTS1,conn,1,1
if rs.eof then
response.write "无记录!"
else
response.redirect "index.asp"
end if
xiwanghope 2003-12-23
  • 打赏
  • 举报
回复
查处记录集以后要先判断是否为空然后再显示数据..

if rsts1.eof then
response.write("none")
else
.... '输出数据
end if

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧