| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 674 人关注过本帖
标题:[求助]关于多重查询的
只看楼主 加入收藏
zzx1213
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-8-7
收藏
 问题点数:0 回复次数:2 
[求助]关于多重查询的
这个是用来实现多重查询的,在没加入decimal类型变量的时候5个条件能实现组合查询,加了序号那个查询条件后也可以实现组合查询.但所有条件为空时查出来的数据不正确了,再加一个条件后不管怎么查,查出来的结果都为空了,谁能告诉我为什么啊?谢谢了!
string ls_txm,ls_kh,ls_lb,ls_czy,ls_pm,ls_rk_no
decimal ld_dj,ld_zk,ld_je,ld_xh
datetime ldt_rkrq,ldt_czrq
string ls_sqlold,ls_where,ls_sqlnew
ls_kh= trim(sle_kh.text)
ls_txm=trim(sle_txm.text)
ls_pm =trim(sle_pm.text)
ls_lb =trim(sle_lb.text)
ls_czy=trim(sle_czy.text)
ls_where =''
//入库单号
ls_rk_no = trim(sle_rk_no.text)
//ld_rk_no =truncate(ls_rk_no,1)
if isnull(ls_rk_no) or ls_rk_no = '' then
ls_where = ls_where
else
ls_where = "rk_no like '" + ls_rk_no + "%'"
end if
//条形码
if isnull(ls_txm) or ls_txm ='' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where = "cg_cprk.txm like '" + ls_txm + "%'"
else
ls_where = ls_where + " and " + "cg_cprk.txm like '" + ls_txm + "%'"
end if
end if
//品名
if isnull(ls_pm) or ls_pm = '' then
ls_where =ls_where
else
if ls_where = '' or isnull(ls_where) then
ls_where = "pm_dm = '" + ls_pm + "'"
else
ls_where = ls_where + " and " + "pm_dm = '" + ls_pm + "'"
end if
end if
//操作员
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
//款号
if isnull(ls_kh) or ls_kh = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" kh_dm like '"+ ls_kh +"%'"
else
ls_where =ls_where + "and " + "kh_dm like'" + ls_kh + "'"
end if
end if
//序号
ld_xh = dec(sle_xh.text)
if isnull(string(dec(ld_xh))) or string(dec(ld_xh)) = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" xh = '"+ string(dec(ld_xh)) +"'"
else
ls_where =ls_where + "and " + "xh ='" + string(dec(ld_xh)) + "'"
end if
end if
//单价
ld_dj = dec(sle_dj.text)
if isnull(string(dec(ld_dj))) or string(dec(ld_dj)) = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" cg_cprk.dj like '"+ string(dec(ld_dj)) +"%'"
else
ls_where =ls_where + "and " + "cg_cprk.dj like'" + string(dec(ld_dj)) + "'"
end if
end if
//折扣
/*ld_zk = dec(sle_zk.text)
if isnull(string(dec(ld_zk))) or string(dec(ld_zk)) = '' then
ls_where =ls_where
else
if ls_where ='' or isnull(ls_where) then
ls_where =" zk = '"+ string(dec(ld_zk)) +"'"
else
ls_where =ls_where + "and " + "zk ='" + string(dec(ld_zk)) + "'"
end if
end if*/
//执行查询
if ls_where = '' or isnull(ls_where) then
w_seek.dw_1.settransobject(sqlca)
w_seek.dw_1.retrieve()
else
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
close(w_seek_filter)
搜索更多相关主题的帖子: 查询 
2006-08-09 13:39
石门书生
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2006-7-14
收藏
得分:0 
眼看花了,你跟踪一下ls_sqlold、ls_sqlnew 、ls_where 前后的变化不就明了吗?

承接定制开发企、事业单位各种信息管理软件 E_mail:gxjnetweb@.cn qq:317359430
2006-08-10 10:36
lilin321
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2006-8-18
收藏
得分:0 
在查询条件中将LIKE部分前后用"()"括起来
2006-08-18 11:08
快速回复:[求助]关于多重查询的
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027651 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved