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 原理就是这样,语法可能有点问题,因为我好久不用了
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
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
原理就是这样,语法可能有点问题,因为我好久不用了
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
LZ不知道会不会连接
用 Label1.Caption=rs.recordcount &"条" '就行了