1,217
社区成员




dim StrSql as string,StrT1 as string,StrT2 as string,StrT3 as string
StrSql="select * from [数据表名] where "
StrT1="工资 > 10000"
StrT2=" and 年龄 <25"
StrT3=" and 性别='女'"
SqlStr=SqlStr & StrT1 & StrT2 & StrT3
connnection.Execute(SqlStr)
代码中StrT1、StrT2、StrT3都是可以根据参数来改变的的。
只是第一个条件当参数为空时,可以用 StrT1="1=1" 这种永远成立的条件来蒙混过去。。。
其他的条件注意前边有个"空格And空格"做条件连接就好了