PB中想动态查询怎么弄?string City,Country,Series,STypeCity=ddlb_dq.tex

PB中想动态查询怎么弄?
string City,Country,Series,SType
City=ddlb_dq.text
Country=ddlb_xs.text
Series=ddlb_xl.text
SType=ddlb_xh.text
string newsql,oldsql
oldsql="select * from product where"
int flag
flag=0
if cbx_dq.checked=true then //地区查询
newsql=oldsql+" product.city = '"+City+"'"
flag=1
end if
if cbx_xs.checked=true then//按县市查询
if flag=0 then
newsql=oldsql+"and product.country ='"+Country+"'"
flag=1
else
newsql=newsql+"and product.country ='"+Country+"'"
end if
end if
if cbx_xl.checked=true then//按系列查询
if flag=0 then
newsql=oldsql+"and product.Series ='"+Series+"'"
flag=1
else
newsql=newsql+"and product.Series ='"+Series+"'"
end if
end if
if cbx_xh.checked=true then//按型号查询
if flag=0 then
newsql=oldsql+"and product.SType ='"+SType+"'"
flag=1
else
newsql=newsql+"and product.SType ='"+SType+"'"
end if
end if
dw_1.Filter()
dw_1.retrieve()
这个答不到筛选效果,还是整张表出现~应该怎么改呢?可以远程教教我吗?
戏游人生 1年前 已收到1个回答 举报

辰萸 春芽

共回答了17个问题采纳率:100% 举报

最下面的语法,FILTER是干什么的?SETFILTER()函数在哪里?
你拼出了SQL,可是没有赋给DW_1,所以即使retrieve,你拼接的SQL也没有起到作用.要使用DW_1.SETSQLSELECT()函数.
从你想表达的意思,FILTER函数应该是没有用的,把那个改成dw_1.setsqlselect(newsql).
再有,你的语句拼接也不对,如果按地区查询的CHECKBOX没有勾中,看看下面的拼接会出现 select .. from where and ...
就是这句,newsql=oldsql+"and product.country ='"+Country+"'"
后边也有.
还有,使用setsqlselect函数时,要求你拼的SQL(newsql)的select字段的顺序和类型都要和你dw_1是一致的,where条件不用一样,还有dw_1不能有参数.

1年前

8
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.041 s. - webmaster@yulucn.com