判断接收的参数是否为null解决思路
判断接收的参数是否为null
接收四个参数,判断四个参数是否为null,根据判断结果,查询数据库,但是没有按照设想执行,这是什么原因??
sybm=request("sybm")
sydd=request("sydd")
jdyf=request("jdyf")
syr=request("syr")
set rs_cjtzd =server.createobject("ADODB.RecordSet")
if (IsNull(sybm) and IsNull(sydd) and IsNull(syr)) then
sql_cjtzd="select * from jdjzjh where sybm is null and sydd is null and syr is null and jdyf='"&jdyf&"'"
end if
if ((Not IsNull(sybm)) and IsNull(sydd) and IsNull(syr)) then
sql_cjtzd="select * from jdjzjh where sybm='"&sybm&"' and sydd is null and syr is null and jdyf='"&jdyf&"'"
end if
if ((Not IsNull(sybm)) and (Not IsNull(sydd)) and IsNull(syr)) then
sql_cjtzd="select * from jdjzjh where sybm='"&sybm&"' and sydd='"&sydd&"' and syr is null and jdyf='"&jdyf&"'"
end if
if ((Not IsNull(sybm)) and (Not IsNull(sydd)) and (Not IsNull(syr))) then
sql_cjtzd="select * from jdjzjh where sybm='"&sybm&"' and sydd='"&sydd&"' and syr='"&syr&"' and jdyf='"&jdyf&"'"
end if
rs_cjtzd.open sql_cjtzd,conn,1,1
------解决方案--------------------
接收四个参数,判断四个参数是否为null,根据判断结果,查询数据库,但是没有按照设想执行,这是什么原因??
sybm=request("sybm")
sydd=request("sydd")
jdyf=request("jdyf")
syr=request("syr")
set rs_cjtzd =server.createobject("ADODB.RecordSet")
if (IsNull(sybm) and IsNull(sydd) and IsNull(syr)) then
sql_cjtzd="select * from jdjzjh where sybm is null and sydd is null and syr is null and jdyf='"&jdyf&"'"
end if
if ((Not IsNull(sybm)) and IsNull(sydd) and IsNull(syr)) then
sql_cjtzd="select * from jdjzjh where sybm='"&sybm&"' and sydd is null and syr is null and jdyf='"&jdyf&"'"
end if
if ((Not IsNull(sybm)) and (Not IsNull(sydd)) and IsNull(syr)) then
sql_cjtzd="select * from jdjzjh where sybm='"&sybm&"' and sydd='"&sydd&"' and syr is null and jdyf='"&jdyf&"'"
end if
if ((Not IsNull(sybm)) and (Not IsNull(sydd)) and (Not IsNull(syr))) then
sql_cjtzd="select * from jdjzjh where sybm='"&sybm&"' and sydd='"&sydd&"' and syr='"&syr&"' and jdyf='"&jdyf&"'"
end if
rs_cjtzd.open sql_cjtzd,conn,1,1
------解决方案--------------------
- VBScript code
sybm = Trim(request("sybm")) sydd = Trim(request("sydd")) jdyf = Trim(request("jdyf")) syr = Trim(request("syr")) If sybm = "" Then sybm = Null If sydd = "" Then sydd = Null If jdyf = "" Then jdyf = Null If syr = "" Then syr = Null ...