一个程序中,要求根据各种爱好查询出相同爱好的成员数据,并显示在DataGrid控键里。
我做了三个checkbox控键,类似如下界面:
口:登山  口:音乐   口:体育    [查询]
----------------------------------------
|                                      |
|                                      |
|                   数据显示           |
|                                      |
|                                      |
----------------------------------------   
在数据库中各个字段的情况如下:
vipID |vipName|vipCity|vipDengshan|vipYinyue|vipTiyu|
数字   字符串  字符串   是/否       是/否     是/否在程序中要求点选上面的checkbox控键,然后查询组合的内部数据,并显示出来。
在这个程序中,命令按狃“查询”的代码应该怎么写?
同时其中的SQL语句应该怎么写合适?
请高手指点!谢谢,急,在线等

解决方案 »

  1.   

    SQL语句
    "select * from XX where vipDengshan=" & chkDengshan.value _
          & " and vipYinyue=" & chkYinyue.value _
          & " and vipTiyu=" * chkTiyu & ";"
      

  2.   

    我的做法是这样的.我是把数据显示在Mshflexgrid 中的.
    private sub Command1_click()
    dim conn as adodb.connection
    dim res as adodb.recordset 
    if res is nothing then
       set res = new adodb.recordset 
    end if 
    if res.state = 1 then
       res.close
    end if 
    dim str as string 
    if check1.value = true then
        str = "select * from AA where vipName ='"& check1.value &"'"
       elseif check2.value =true then
         str ="select * from AA where vipName ='"& check2.value &"'"
       elseif check3.value = true then
         str ="select * from AA where vipName ='"& check3.value &"'"
    end if 
    res.open str,conn,自己写,自己写
    if not res.eof then
       set.Mshflexgrid1.recordset = res
    else
       msgbox "没有相关数据!"
       mshflexgrid1.clear
    end if 
    end sub
    试试看吧
      

  3.   

    str = "select * from AA where vipdengshan ='"& check1.value &"'"str=str & " And vipyinyue='"&check2.value &"' "str=str &" AND viptiyu='"&check3.value &"' "更正一下楼上那位的笔误而已.