我做了一个多重查询的程序.表内数据有string和date类型,
//操作员
if isnull(ls_czy) or ls_czy = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where = "gg_cpzl.czy like'" + ls_czy + "%'"
else
ls_where =ls_where + "and " + "gg_cpzl.czy like'" + ls_czy + "'"
end if
end if
//类别
if isnull(ls_lb) or ls_lb = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" lb_dm like '"+ ls_lb +"%'"
else
ls_where =ls_where + "and " + "lb_dm like'" + ls_lb + "'"
end if
end if
//入库日期
ldt_rkrq1 = datetime(sle_rkrq1.text)
ldt_rkrq2 = datetime(sle_rkrq2.text)
if isnull(ldt_rkrq1) then
ldt_rkrq1 =datetime(1900-01-01)
end if
if isnull(ldt_rkrq2) then
ldt_rkrq2 = datetime(1900-01-01)
end if
if ldt_rkrq1 <> datetime(1900-01-01) then
ls_where = ls_where + "rkrq >= '"+string(datetime(date(ldt_rkrq1),00:00:00))+"' and "
end if
if ldt_rkrq2 <> datetime(1900-01-01) then
ls_where = ls_where + " rkrq <= '" + string(datetime(date(ldt_rkrq2),23:59:59)) + "' and "
end if
//执行查询
if ls_where = '' or isnull(ls_where) then
w_seek.dw_1.settransobject(sqlca)
w_seek.dw_1.retrieve()
else
//ls_where = left(ls_where,len(ls_where) - 2)
w_seek.dw_1.settransobject(sqlca)
ls_sqlold = w_seek.dw_1.getsqlselect()
ls_sqlnew = ls_sqlold + ' and ' + ls_where
w_seek.dw_1.setsqlselect(ls_sqlnew)
w_seek.dw_1.retrieve()
w_seek.dw_1.setsqlselect(ls_sqlold)
end if
if w_seek.dw_1.rowcount() > 0 then
messagebox("查询结果!","总共查询到"+string(w_seek.dw_1.rowcount())+"条记录符合查询内容!",information!,ok!)
end if
为什么查询出来的结果总为空,前面2个条件一起的时候是没有问题的,所有我猜想是第3个条件进行数据转换的时候出问题了.谁能告诉我哪里错了啊.