读书人

asp类型不匹配

发布时间: 2012-07-04 19:33:55 作者: rapoo

求助,asp类型不匹配
<%option Explicit%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/functions.asp"-->
<%
Checklogin()
CheckRight()
%>

<%
dim HouseTypeID,Room,Hall,Status,RegionID,xingzheng,HouseID,phone,i,page,sql,rs,bg,saleOrRent,price1,price2,area1,area2,district,jiegou,floor1,floor2
dim BeginDate,EndDate,pageStr,code,fwxz,tuijian,yaoshi
HouseID=Request("HouseID")
Code=Request("HouseID")
saleOrRent=Request("SaleOrRent")
HouseTypeID=Request("HouseTypeID")
fwxz=Request("fwxz")
jiegou=Request("jiegou")
RegionID=Request("RegionID")
floor1=Request("floor1")
floor2=Request("floor2")
xingzheng=Request("xingzheng")
district=Trim(Request("District"))
price1=Request("price1")
price2=Request("price2")
if request("tuijian")<>"" then
tuijian=1
end if
if request("yaoshi")<>"" then
yaoshi=1
end if
area1=Request("area1")
jiegou=Request("jiegou")
area2=Request("area2")
if RegionID="" then RegionID=0
if xingzheng="" then xingzheng=0
if HouseTypeID="" then HouseTypeID=0
Room=Trim(Request("Room"))
if Room="" then Room=-1
Hall=Trim(Request("Hall"))
if Hall="" then Hall=-1
Status=Request("Status")
if Status="" then
Status=-2
else
Status=cint(Status)
end if
beginDate=Request("dteBegDate")
'If begindate<"2006-07-01" Then
'begindate="2006-07-01"
'End if
endDate=Request("dteEndDate")
'If endDate<"2006-07-01" Then
'endDate="2006-07-01"
'End if
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>房源查询</title>
<script language="JavaScript" src="../js/calendar.js"></script>
<script language=javascript>
function post_fun(id,strType){
//window.location = "house_search_info.asp?SaleOrRent="+strType+"&id="+id
window.location = "house_search_info.asp?id="+id
}
</script>
<link rel="stylesheet" href="../css/style.css" type="text/css">
<base target="_self">
</head>

<body topmargin="0" leftmargin="0" bgcolor="#FFFFCA">
<!--#include file="house_search_menu.asp"-->
<br>

<%
function Search(strTit)
%>
<div align="center">
<table width="800" border=0 ID="Table1" class=Xsmall height="79">
<form name=form1 action="house_search.asp?SaleOrRent=<%=Request("SaleOrRent")%>&tuijian=<%=Request("tuijian")%>" method=post >
<tr>
<td height="29" align=left> 房源编号:<input type='text' class="inpbox1" size=10 name='HouseID' value='<%=Request("HouseID")%>'>
小区:<font color=#a52a2a><input type='text' class="inpbox1" size=10 name='district' value='<%=Request("district")%>' ></font>
区域:<select name=RegionID style="WIDTH: 50px">
<option value="">不限</option>


<%call RegionSelect(cint(RegionID))%>
</select>
行政:<select name=xingzheng style="WIDTH: 50px">
<option value="">不限</option>
<%call xingzhengSelect(cint(xingzheng))%>
</select>
登记时间:<input type='text' class="inpbox1" size=9 name='dteBegDate' value='<%=Request("dteBegDate")%>' onClick="fPopCalendar(dteBegDate,dteBegDate,'Down');return false" >
-
<input type='text' class="inpbox1" size=9 name='dteEndDate' value='<%=Request("dteEndDate")%>' onClick="fPopCalendar(dteEndDate,dteEndDate,'Down');return false" >
钥匙<font color="#FF00FF"><input type="checkbox" name="yaoshi" value="1"></font>
<!--本店
<input name="bendian" type="checkbox" id="bendian" value="1">-->
</td>
</tr>
<tr>
<td height="44" align=left valign="top"> <select name="Room" >
<option value="">不限</option>
<%RoomSelect(cint(Room))%>
</select>

<select name="Hall" >
<option value="">不限</option>
<%HallSelect(cint(Hall))%>
</select>
厅 价格:<input type='text' class="inpbox1" size=5 name='price1' value='<%=Request("price1")%>' >
-
<input type='text' class="inpbox1" size=5 name='price2' value='<%=Request("price2")%>' >
面积:<input type='text' class="inpbox1" size=5 name='area1' value='<%=Request("area1")%>' >
-
<input type='text' class="inpbox1" size=5 name='area2' value='<%=Request("area2")%>' >
<%if SaleOrRent="Rent" then%>
房屋结构:<select name="jiegou" id="jiegou" >
<option value="" >不限</option>
<option value="单" <%if jiegou="单" then Response.Write("selected")%>>单</option>
<option value="套" <%if jiegou="套" then Response.Write("selected")%>>套</option>
<option value="组" <%if jiegou="组" then Response.Write("selected")%>>组</option>
</select>
<%else%>
房屋性质:<input name='fwxz' type='text' class="inpbox1" value='<%=Request("fwxz")%>' size=5 >
<%end if%>
楼层:<input name='floor1' type='text' class="inpbox1" id="floor1" value='<%=Request("floor1")%>' size=3 >
-
<input name='floor2' type='text' class="inpbox1" id="floor2" value='<%=Request("floor2")%>' size=3 >
<!--<font color="#FF00FF">推荐房源</font>
<label>
<input type="checkbox" name="tuijian" value="1">
  </label> -->
<input type="submit" class="btnbox1" value="查询" name="Button1" id="Submit1">
</td></form></tr>
</table>
</div>
<%
end function

function SaleList() '出售
i=1
page=Request("page")


if page="" or not isnumeric(page) then
page=1
else
page=cint(page)
end if
Sql="select * from v_SaleHouse where salestatus=1 and cityid="+"'"+session("cityid")+"'"

if xingzheng <>0 then
sql = sql & " and xingzheng = "&xingzheng
end if

if RegionID <>0 then
sql = sql & " and RegionID = "&RegionID
end if



if HouseID<>"" then
Sql=Sql & " and (houseid like '%"&HouseID&"%' or Code like '%"&HouseID&"%')"
end if

if price1<>"" then
sql=sql &" and Price>="+price1
end if

if tuijian <> "" then
sql = sql & " and tuijian=1"
end if

if yaoshi <> "" then
sql = sql & " and yaoshi=1"
end if

if price2<>"" then
sql=sql &" and Price<="+price2
end if

if District<>"" then
sql=sql &" and ((DistrictName like"+"'%"+District+"%') or "+"(py like "+"'%"+District+"%'))"
end if

if area1<>"" then
sql=sql &" and area>="+area1
end if

if area2<>"" then
sql=sql &" and area<="+area2
end if

if floor1<>"" then
sql=sql &" and floor>="+floor1
end if

if floor2<>"" then
sql=sql &" and floor<="+floor2
end if


if HouseTypeID<>0 then
Sql=Sql & " and HouseTypeID="&HouseTypeID
end if
if Room<>-1 then
Sql=Sql & " and Room=" & Room
end if
if Hall<>-1 then
Sql=Sql & " and Hall=" & Hall
end if
if Request("Address")<>"" then
Sql=Sql & " and Address like '%"&Request("Address")&"%'"
end if

if Request("fwxz")<>"" then
Sql=Sql & " and fwxz like '%"&Request("fwxz")&"%'"
end if

if Request("HostName")<>"" then
Sql=Sql & " and HostName like '%"&Request("HostName")&"%'"
end if
if Status<>-2 then
Sql=Sql & " and SaleStatus="&Status
end if
if Request("HostIdCard")<>"" then
Sql=Sql & " and HostIdCard like '%"&Request("HostIdCard")&"%'"
end if
if Request("RegIdCard")<>"" then
Sql=Sql & " and RegIdCard like '%"&Request("RegIdCard")&"%'"
end if
if Request("Phone")<>"" then
Sql=Sql & " and ((RegPhone = '"&phone&"') or (RegMbPhone='"&phone&"') or (HostPhone='"&Phone&"') or (HostMbPhone='"&Phone&"'))"
end if

if Request("dteBegDate")<>"" then
Sql=Sql & " and RegDate>='"&Request("dteBegDate")&"'"
end if

if Request("dteEndDate")<>"" And Request("dteEndDate")>"2006-07-01" then
Sql=Sql & " and RegDate<='"&Request("dteEndDate")&"'"
end if






Sql = Sql & " order by RegDate Desc"
Set RS=Server.CreateObject("ADODB.Recordset")
RS.Open Sql,Conn,1,3

%>

<div align=center class=Xsmall><font color=#6F2400>出售房源查询</font><%if Rs.Recordcount>0 then Response.write ("("+Cstr(Rs.Recordcount)+")")%></div>
<%Search("售")%>

<%
if not RS.EOF then
RS.PageSize = 15
RS.AbsolutePage = page

%>

<div align="center">

<table width="820" border="0" bgcolor="#999999" cellspacing="1" cellpadding="1" class="Xbig" ID="Table2">
<tr align=center bgcolor="#D7D7D7">
<td width="9%" height="30" bgcolor="#FF9933">房源编号</td>
<!-- <td width="65">内部编码</td>-->
<!--<td>区域</td>-->
<!--<td width="29">推荐</td>-->
<td width="9%" bgcolor="#FF9933">登记时间</td>
<td width="13%" bgcolor="#FF9933">小区</td>

<!--<td>房型</td>-->
<td width="5%" bgcolor="#FF9933">楼层</td>
<td width="5%" bgcolor="#FF9933">楼型</td>
<td width="7%" bgcolor="#FF9933">面积(M<sup>2</sup>)</td>
<td width="10%" bgcolor="#FF9933">单价(元/M<sup>2</sup>)</td>

<td width="7%" bgcolor="#FF9933">价格(万)</td>
<!--<td>状态</td>-->
<td width="24%" bgcolor="#FF9933">装修</td>
<!--<td width="29">钥匙</td>-->
<td width="6%" bgcolor="#FF9933">操作</td>
<!--<td>备注</td>-->
</tr>
<%
while not RS.EOF and i <= RS.PageSize
if i mod 2=0 then
bg="#F6F6F6"
else
bg="#ffffff"
end if
%>
<tr bgcolor="<%=bg%>" align=center onMouseOver="this.bgColor='#ffcc66';this.style.cursor='hand';" onMouseOut="this.bgColor='<%=bg%>'" onClick="post_fun('<%=RS("HouseID")%>','Sale')">
<td height="30"><%=RS("HouseID")%></td>
<!--<td> if rs("tuijian")=true then response.Write "<font color='ff0000'>★</font>" %></td>-->
<!--<td>=RS("Code")%></td>-->
<!--<td><=RS("Region")%></td>-->
<td><%=RS("RegDate")%></td>
<td><%=RS("DistrictName")%></td>
<!--<td> =RS("Room")%>室 =RS("Hall")%>厅</td>-->
<td><%=RS("Floor")%>/<%=RS("TotalFloor")%></td>
<td><%=RS("HouseType")%></td>
<td><%=RS("Area")%></td>
<td><%if RS("sqmprice")<>"" then %><%=RS("sqmprice")%><%else%><%=RS("danjia")%><%end if%></td>
<!--<td align=left><%=RS("Remark")%></td>-->


[解决办法]
cint(xingzheng) xingzheng是Request中取的,不能保证是数字,先做一下判断

VBScript code

If IsNumeric(xingzheng) Then    xingzheng = CInt(xingzheng)Else    xingzheng = 0End If
[解决办法]
再看了看。

xingzheng的变量有可能不是数字。所以你要cint的时候,会出错。

if not isnumeric(xingzheng) then
xingzheng = 0
end if
[解决办法]
既然是文本型的数据,我建议判断改为。

if len(xingzheng) >0 或者 xingzheng <>"" then
sql = sql & " and xingzheng = '"&xingzheng&"'"
end if
[解决办法]
关于这个要修改两个地方:
第一:
修改方法xingzhengSelect中的判断语句为以下:

if len(xingzheng) >0 或者 xingzheng <>"" then
sql = sql & " and xingzheng = '"&xingzheng&"'"
end if

第二:
再把<%call xingzhengSelect(cint(xingzheng))%>
改成<%call xingzhengSelect(xingzheng)%>

读书人网 >ASP

热点推荐