VB 查询数据库某一字段的所有内容
展开全部
dim i as long '计数
dim conn as new adodb.connention
dim rs as new adodb.recordset
private sub commad1_click()
rs.Open "select * from table", conn, adOpenKeyset, adLockOptimistic
if rs.RecordCount<> 0 then '查询数据库是否为空
for i=0 to rs.RecordCount-1
if zy=rs.filed("姓名") then '判断所查数据是否等于zy
i=i+1 '等于则计数加一
endif
rs.movenext
next i
enif
end sub
dim conn as new adodb.connention
dim rs as new adodb.recordset
private sub commad1_click()
rs.Open "select * from table", conn, adOpenKeyset, adLockOptimistic
if rs.RecordCount<> 0 then '查询数据库是否为空
for i=0 to rs.RecordCount-1
if zy=rs.filed("姓名") then '判断所查数据是否等于zy
i=i+1 '等于则计数加一
endif
rs.movenext
next i
enif
end sub
展开全部
如果新建一个自动编号(递增)字段的话,则不必写ADO,在查询QBE新建一个字段即可:
计数:Dcount("姓名","表","姓名='xy' and 编号<="&[编号])
计数:Dcount("姓名","表","姓名='xy' and 编号<="&[编号])
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim
i
as
long
'计数
dim
conn
as
new
adodb.connention
dim
rs
as
new
adodb.recordset
private
sub
commad1_click()
rs.Open
"select
*
from
table",
conn,
adOpenKeyset,
adLockOptimistic
if
rs.RecordCount<>
0
then
'查询数据库是否为空
for
i=0
to
rs.RecordCount-1
if
zy=rs.filed("姓名")
then
'判断所查数据是否等于zy
i=i+1
'等于则计数加一
endif
rs.movenext
next
i
enif
end
sub
i
as
long
'计数
dim
conn
as
new
adodb.connention
dim
rs
as
new
adodb.recordset
private
sub
commad1_click()
rs.Open
"select
*
from
table",
conn,
adOpenKeyset,
adLockOptimistic
if
rs.RecordCount<>
0
then
'查询数据库是否为空
for
i=0
to
rs.RecordCount-1
if
zy=rs.filed("姓名")
then
'判断所查数据是否等于zy
i=i+1
'等于则计数加一
endif
rs.movenext
next
i
enif
end
sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询