怎样从数据库中查到的记录数目,并把它用Label显示出来啊?
比如说:身高为170的数据在数据库里有5条记录,那就显示5。

解决方案 »

  1.   

    select count(*) form tablename where height = 170
      

  2.   

    select count(*) as 别名 form 表名 where 身高 = 170
      

  3.   

    dim i,j as integer  i=0
    Set db = OpenDatabase("1.mdb")
    Set rs = db.OpenRecordset("表名")
    rs.open"select*form 表名where 身高=170 "
    rs.movefirst
    for  j=1 to  .recordcount
       if .filed("身高")=170 then
         i=i+1
       end if
    if j<.recordcount then .movenext
    next j,
    然后把i赋值过去就行了,label不能用,要用text
    原理就是这样,语法可能有点问题,因为我好久不用了
      

  4.   

    dim rs as new adodb.recordset
    dim sql as string
    sql=" select count(*) as icount from 表名 where 身高=170"
    if rs.state<>adstateclosed then rs.close
    rs.open sql,conn,adopenkeyset,adlockreadonly
    if rs.recordcount>0 then
        if not isnull(rs!icount) then
            label.caption=rs!count
            label.refresh
        end if
    end if
    rs.close
      

  5.   

    conn要声明一下撒
    LZ不知道会不会连接
      

  6.   

    晕!有这么复杂嘛! 楼主肯定已经找出那5条记录了    
    用  Label1.Caption=rs.recordcount &"条"   '就行了