If check_ZongHe_JiaGe.Value = 1 Then
ElseIf combo_JiaGe.Text = "<10元" Then
sql = "select * from books where bk_pri < 10"
ElseIf combo_JiaGe.Text = "<20元" Then
sql = "select * from books where bk_pri < 20"
ElseIf combo_JiaGe.Text = "<50元" Then
sql = "select * from books where bk_pri < 50"
ElseIf combo_JiaGe.Text = "<100元" Then
sql = "select * from books where bk_pri < 100"
ElseIf combo_JiaGe.Text = ">50元" Then
sql = "select * from books where bk_pri > 50"
ElseIf combo_JiaGe.Text = ">100元" Then
sql = "select * from books where bk_pri > 100"
End Ifcn.ConnectionString = "driver={SQL Server};" & _
"server=note;uid=;pwd=;database=pubs"
cn.CursorLocation = adUseClient
cn.Openrs.CursorLocation = adUseClient
rs.Open sql, cn, adOpenKeyset, adLockOptimistic

解决方案 »

  1.   

    字段bk_pri 是什么类型?
    出错信息贴出来看看.
      

  2.   

    rs.Open sql, cn, adOpenKeyset, adLockOptimistic,adCmdText
      

  3.   

    bk_pri类型是smallmoney
    出错信息是:“没有为命令对象设置命令“
    我调试的时候总是显示  sql=""
      

  4.   

    If check_ZongHe_JiaGe.Value = 1 Then
    是不是这个条件不成立
      

  5.   

    不会阿,这个条件不就是判断check控件是不是选中吗?
    我定义的如果不选中的话combo_JiaGe.enable=false的
      

  6.   

    你的可能要写成这样
    If check_ZongHe_JiaGe.Value = 1 Then
      If combo_JiaGe.Text = "<10元" Then
         sql = "select * from books where bk_pri < 10"
      ElseIf combo_JiaGe.Text = "<20元" Then
         sql = "select * from books where bk_pri < 20"
      ElseIf combo_JiaGe.Text = "<50元" Then
         sql = "select * from books where bk_pri < 50"
      ElseIf combo_JiaGe.Text = "<100元" Then
         sql = "select * from books where bk_pri < 100"
      ElseIf combo_JiaGe.Text = ">50元" Then
         sql = "select * from books where bk_pri > 50"
      ElseIf combo_JiaGe.Text = ">100元" Then
         sql = "select * from books where bk_pri > 100"
      EndIf
    End If
      

  7.   

    是你的判断语句的问题么!
    If check_ZongHe_JiaGe.Value = 1 Then
    '这里的判断有问题了,怎么会是elseif呢
    ElseIf combo_JiaGe.Text = "<10元" Then
    ————————
    End If
    当你的checkbox选中后,并没有给sql设置语句阿
    你在重新看一下
      

  8.   

    你的判断逻辑写的有问题。对combo_JiaGe.Text的判断体为什么不用Select Case呢?这样要清晰很多。