为何总是执行else语句

a97191 2006-05-19 02:23:38
<!--#include file="../conn/conn.asp"-->


<table align="center">
<tr>
<form action="" method="post" name="form1">
<td width="420">型号:<input type="text" name="typeno" size=12>  序列号:
<input type="text" name="typename" size=16><input type="submit" value="查找"></td>
</form>   <form action="typeno_excel.asp"><td width="380">日期<input type="textbox" name="fix_date" value=<%=date%> size="12">
型号:<input type="textbox" name="typeno1" size="12"><input type="submit" value="导入excel"></td></form>

</tr>

</table>

<%
dim type1,type2
type1="ddd"
type2="ddd"
if Request("typename")<>"" then
type1=trim(Request("typename"))
end if

if Request("typeno")<>"" then
type2=trim(Request("typeno"))
end if

set cmd=server.CreateObject("adodb.command")
cmd.ActiveConnection=conn
cmd.CommandText="dbo.mainboard_selectT"
cmd.CommandType=4
cmd.Prepared=true
cmd.Parameters.Append cmd.CreateParameter("@typename",200,1,50,type1)
cmd.Parameters.Append cmd.CreateParameter("@typeno",200,1,50,type2)
set rs=server.CreateObject("adodb.recordset")

rs.open cmd,,1,1
rs.pagesize=20
if not isEmpty(request("topage")) then
topage=cInt(request("topage"))
if topage>rs.pageCount then
rs.absolutePage=rs.PageCount
elseif topage<=0 then
rs.absolutePage=1
else
rs.absolutePage=topage

end if
else
topage=1
end if
%>


<table width=839 height=1 border=1 align="center" cellPadding=3 cellSpacing=0 borderColorLight=#008000 borderColorDark=#ffffff
bgColor=#e6f2e7>
<%
for i=1 to rs.pagesize
if rs.eof then
exit for
end if
if rs.eof then
exit for
end if
%>
<tr>
<td><% if rs("repair")=true then%><input type="checkbox" name="check" checked><%else%><input type="checkbox" name="check" onclick="window.location.href='fix_ruku.asp?id=<%=rs("id")%>&topage=<%=topage%>&key=<%=request("typename")%>&tt=3';"><%end if%></td>

<td><%=rs("typeno")%></td>
<td><%=rs("typename")%></td>
<td><%=rs("fix_date")%></td>
<td><%=rs("linkman")%></td>
<td><%=rs("tel")%></td>
<td> <%=rs("fix_state")%> </td>
<td>

<% if trim(rs("fix_state"))="S" then%>
<%=datediff("d",rs("fix_date"),rs("ruku_date"))%>

<%else%> 
<%end if%>
</td>
<td>
<%
if rs("cc")<>0 then
response.write rs("cc")
end if
%>
</td>
<td><%=rs("dd")%></td>
<td> <%=rs("module_cord")%> </td>
<td> <%=rs("module_code")%> </td>
<td> <%=rs("error_code")%> </td>
<td> <%=rs("remark")%></td>
<td> <%=rs("beizhu")%></td>
<td> <%=rs("remark1")%></td>
<td> <%if rs("price")>0 then%><font color="red"><%=rs("price")%></a><%end if%></td>
<td>
<% if rs("checks")=false then response.write "正在维修中.." else response.write "<font color=red>维修完成</font>" end if%>
</td>
<td> <%=rs("finish_date")%></td>
<td><a href="modify.asp?id=<%=rs("id")%>&tt=3&key=<%=request("typename")%>">修改</a> <a href="finish.asp?id=<%=rs("id")%>&tt=3&key=<%=request("typename")%>">完成</a></td>
<td width="41"><div align="center">
<% if rs("draw")=false then response.write "<a href=draw.asp?id="&rs("id")&"&tt=3&key="&request("typename")&">未领</a>" else response.write "<font color=red>已领</font>" end if%></div></td>
<td> <%=rs("drawdate")%></td>
<td> <%=rs("content")%></td>
<td><%if rs("ruku")=true then%><input type="checkbox" name="check" checked>
<%else%><input type="checkbox" name="check" value=<%=rs("id")%> onclick="window.location.href='ruku_type.asp?id=<%=rs("id")%>&key=<%=request("typename")%>'"><%end if%></td>
<td><%if rs("baobiao")<>"" then%><input type="checkbox" name="baobiao" value="" checked>
<%else%>
<input type="checkbox" name="baobiao" onclick="window.location.href='baobiao.asp?id=<%=rs("id")%>&topage=<%=topage%>&key=<%=request("typename")%>&tt=3';"><%end if%></td>
<td><% if session("limit")=1 then%><a href="finish_modify.asp?id=<%=rs("id")%>&key=<%=request("typename")%>">修改</a><%end if%></td>
</tr>
<%
rs.movenext
next
%>
</table>

<%
cmd.close
set cmd=nothing
rs.close
set rs=nothing

conn.close
set conn=nothing
%>
</body>
存储过程
create procedure mainboard_selectT
@typeno varchar(50),
@typename varchar(50)
as

if ltrim(Rtrim(@typename))!='ddd' and ltrim(rtrim(@typeno))='ddd'
select id,repair,typeno,typename,fix_date,linkman,tel, fix_state,checks,
module_cord,module_code,error_code,remark,beizhu,remark1,price,finish_date,
draw,drawdate,content,ruku,baobiao,cc=(case when (repair=1 and checks=0) then datediff(day,ruku_date,getdate()) else 0 end),
dd=(select count(1) from mainboard where typename=a.typename group by typename) from mainboard a
where typename like '%' +ltrim(rtrim(@typename))+'%' order by fix_date desc
else 'asp总是执行下面的语句

select id,repair,typeno,typename,fix_date,linkman,tel, fix_state,checks,
module_cord,module_code,error_code,remark,beizhu,remark1,price,finish_date,
draw,drawdate,content,ruku,baobiao,cc=(case when (repair=1 and checks=0) then datediff(day,ruku_date,getdate()) else 0 end),
dd=(select count(1) from mainboard where typename=a.typename group by typename) from mainboard a
...全文
132 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
a97191 2006-05-22
  • 打赏
  • 举报
回复
还是自己解决了
a97191 2006-05-19
  • 打赏
  • 举报
回复
这个问题已经解决,但rs.recordcount和rs.pagecount都是-1?为什么?
邦迪代驾 2006-05-19
  • 打赏
  • 举报
回复
不好意思,上面写错了,忘了这是存储过程
邦迪代驾 2006-05-19
  • 打赏
  • 举报
回复
if ltrim(Rtrim(@typename))!='ddd' and ltrim(rtrim(@typeno))='ddd' then
检查数据类型和字段类型一致吗
a97191 2006-05-19
  • 打赏
  • 举报
回复
我知道没有满足条件,但是如何改呢
竹林听雨2005 2006-05-19
  • 打赏
  • 举报
回复
那你上面的条件肯定没满足呀
a97191 2006-05-19
  • 打赏
  • 举报
回复
就是说,总是显示存储过程的else部分
dim type1,type2
type1="ddd"
type2="ddd"
if Request("typename")<>"" then
type1=trim(Request("typename"))
end if

if Request("typeno")<>"" then
type2=trim(Request("typeno"))
end if

set cmd=server.CreateObject("adodb.command")
cmd.ActiveConnection=conn
cmd.CommandText="dbo.mainboard_selectT"
cmd.CommandType=4
cmd.Prepared=true
cmd.Parameters.Append cmd.CreateParameter("@typename",200,1,50,type1)
cmd.Parameters.Append cmd.CreateParameter("@typeno",200,1,50,type2)
set rs=server.CreateObject("adodb.recordset")

rs.open cmd,,1,1

存储过程
create procedure mainboard_selectT
@typeno varchar(50),
@typename varchar(50)
as

if ltrim(Rtrim(@typename))!='ddd' and ltrim(rtrim(@typeno))='ddd'
select id,repair,typeno,typename,fix_date,linkman,tel, fix_state,checks,
module_cord,module_code,error_code,remark,beizhu,remark1,price,finish_date,
draw,drawdate,content,ruku,baobiao,cc=(case when (repair=1 and checks=0) then datediff(day,ruku_date,getdate()) else 0 end),
dd=(select count(1) from mainboard where typename=a.typename group by typename) from mainboard a
where typename like '%' +ltrim(rtrim(@typename))+'%' order by fix_date desc
else 'asp总是执行下面的语句

select id,repair,typeno,typename,fix_date,linkman,tel, fix_state,checks,
module_cord,module_code,error_code,remark,beizhu,remark1,price,finish_date,
draw,drawdate,content,ruku,baobiao,cc=(case when (repair=1 and checks=0) then datediff(day,ruku_date,getdate()) else 0 end),
dd=(select count(1) from mainboard where typename=a.typename group by typename) from mainboard a
clbaddd 2006-05-19
  • 打赏
  • 举报
回复
代码太长了,看着都晕.
帮你顶一下

28,391

社区成员

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

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