VB怎么样查询出几个结果

beyondgo 2009-05-28 12:49:47
我有一个表list如下:
A
1
2
2
3
6
9
8

数据库连接如下:
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\TM.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select count(A) from list where A= 8"
Adodc1.Refresh
Text1.Text = Adodc1.Recordset.Fields(0)

我现在可以查询A字段中8出现的次数.


我的目标是:想查询出,1,2 ,3等数字出现的次数.
在几个TEXT中显示出来.

...全文
317 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
beyondgo 2009-05-28
  • 打赏
  • 举报
回复
用数组的形式是可以的,如果没有别的更快的方法也只有用这种方法的
我的数字比较多,如果一次可以查几个数的就好了
vbman2003 2009-05-28
  • 打赏
  • 举报
回复
错了:

Adodc1.RecordSource = "select A,count(A) as c from list group by A"
Adodc1.Refresh
while not Adodc1.RecordSourc.eof
text1(Adodc1.Recordset.Fields("A")).text=Adodc1.Recordset.Fields("c") '用text1控件数组
Adodc1.RecordSourc.movenext
wend

没用过Adodc,用习惯了ADO对象...
vbman2003 2009-05-28
  • 打赏
  • 举报
回复

Adodc1.RecordSource = "select A,count(A) as c from list group by A"
Adodc1.Refresh
while not Adodc1.RecordSourc.eof
text1(rs!A).text=rs!c '用text1控件数组
Adodc1.RecordSourc.movenext
wend
tongnaifu 2009-05-28
  • 打赏
  • 举报
回复
2楼可以
LWMWORK 2009-05-28
  • 打赏
  • 举报
回复
做text控件数组,试试
for i=0 to 9
Adodc1.RecordSource = "select count(A) from list where A= " & i
Adodc1.Refresh
Text1(i).Text = Adodc1.Recordset.Fields(0)
next
clear_zero 2009-05-28
  • 打赏
  • 举报
回复
Adodc1.RecordSource = "select A,count(A) as c from list group by A"
Adodc1.Refresh
while not Adodc1.RecordSourc.eof
text1(Adodc1.Recordset.Fields("A")).text=Adodc1.Recordset.Fields("c") '用text1控件数组
Adodc1.RecordSourc.movenext
wend

beyondgo 2009-05-28
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 beyondgo 的回复:]
一次可以执行如下的查询就好了
a1 = select aount(A) form list where A= 10 or a=11 .....
a2 = select aount(A) form list where A= 20 or a=11 .....
a3 = select aount(A) form list where A= 30 or a=11 .....

用什么方法都行,只要方便就行,
能用就行
[/Quote]

SQL语句我知道,我想知道在VB里怎么实现.
tongnaifu 2009-05-28
  • 打赏
  • 举报
回复
select count(A) from list where A in(1,2,3,4)
beyondgo 2009-05-28
  • 打赏
  • 举报
回复
一次可以执行如下的查询就好了
a1 = select aount(A) form list where A= 10 or a=11 .....
a2 = select aount(A) form list where A= 20 or a=11 .....
a3 = select aount(A) form list where A= 30 or a=11 .....

用什么方法都行,只要方便就行,
能用就行
beyondgo 2009-05-28
  • 打赏
  • 举报
回复
顶啊,有没有人来啊

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧