首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

判断接收的参数是否为null解决思路

2012-04-03 
判断接收的参数是否为null接收四个参数,判断四个参数是否为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


[解决办法]

VBScript code
sybm = Trim(request("sybm"))sydd = Trim(request("sydd"))jdyf = Trim(request("jdyf"))syr = Trim(request("syr"))If sybm = "" Then sybm = NullIf sydd = "" Then sydd = NullIf jdyf = "" Then jdyf = NullIf syr = "" Then syr = Null... 

热点排行