如何用ListView显示从数据库查询出来的汇总数据?

tianbigao 2008-03-07 07:41:47
我有一个SQL是这样的:select sum(case number when 0 then 1 else 0 end), sum(case number when 1 then 1 else 0 end) from result 我想把Result表里的number字段0和1出现的次数汇总,然后用ListView来显示,不知怎么做,请高手们帮帮忙?
...全文
274 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
meiZiNick 2008-05-01
  • 打赏
  • 举报
回复
关注 接分
linbo_xiao 2008-03-11
  • 打赏
  • 举报
回复
Dim tmprs As New ADODB.Recordset
dim adoconnect as new adodb.connection
'在加入这里打开数据库连接的代码
'在窗体上面加入一个ListView控件,并增加两个栏位

tmprs.Open "select sum(case number when 0 then 1 else 0 end), sum(case number when 1 then 1 else 0 end) from result ", adoconnect, adOpenStatic, adLockReadOnly

i = 1
Do While Not tmprs.EOF()
ListView1.ListItems.Add
ListView1.ListItems(i).SubItems(1).Text = tmprs(0)
ListView1.ListItems(i).SubItems(2).Text = tmprs(1)
tmprs.MoveNext
i = i + 1
Loop

tmprs.Close
tianbigao 2008-03-11
  • 打赏
  • 举报
回复
太伤心了,没有一个人帮我!!!

2,462

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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