完整的三重条件检索语句

 最后的三重检索语句如下:
Dim d1, d2 As Date
        d1 = Date_quest_buy_buybl_start.Value.Date
        d2 = Date_quest_buy_buybl_end.Value.Date
        Dim sup, key As String
        If Check_quest_buybl_supplyer.Checked = True Then
            sup = ""
        Else
            sup = ComboBox_quest_buy_buybl_supplyer.Text

        End If
' 这里增加了一个CHECKBOX控件,以判断第二个检索是否起作用。
        key = tex_quest_buybl_key.Text


        OleDbConnection2.Open()
        OleDb_quest_taobao_buybl.SelectCommand.CommandText = "select * from (select * from (select * from buy_bl where buy_date between #" + d1 + "#  and #" + d2 + "#) where [supplyer] like '%" + sup + "%') where [blno] like '%" + key + "%'and [blno] not like '%rebu%'and [blno] not like '%monkey%' and [blno] not like '%aibei%'"

‘这里字符串检索全部用了like运算符而没有用=运算符是因为用like “% 变量名%”时,当变量为空时会选择全部字符串。另外要注意红色的部分,这里用了not 来排除一些特定的字段。
        OleDb_quest_taobao_buybl.Fill(DataSet_quest_taobao_buybl1)
        OleDbConnection2.Close()

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值