问题描述:
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()
这个答不到筛选效果,还是整张表出现~应该怎么改呢?可以远程教教我吗?
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()
这个答不到筛选效果,还是整张表出现~应该怎么改呢?可以远程教教我吗?
问题解答:
我来补答展开全文阅读