how to display select count result in listview
hi,
there is branches such A,B,C etc. Customers get authorization at this branches and such failed,success result status in my sql table .
i want display this informations sending from database to listview using vb6.
how can i display sql count result in listview ? (total of records at 3.column)
for example;
A success 120
A failed 30
B success 110
B failed 20
C success 120
C failed 30
codes:
With rs.ActiveConnection = cn
.Open "select branches , status, COUNT(*) from mytable where date between '20120410 15:00:00' and '20120411 16:00:00' group by branches,status order by branches,status"
Dim branches,status As String
Do While Not rs.EOF
BRANCHES= rs("BRANCHES")
STATUS= rs("STATUS")
Set list = ListView1.ListItems.Add(, , File)
list.SubItems(1) = branches
list.SubItems(2) = status
rs.MoveNext
Loop
Re: how to display select count result in listview
Hi, Welcome to the forums..
Next time when you post your code fragments, enclose it like this:
[CODE]your code goes here[/CODE]
Regarding your question, maybe you could try it like this:
Code:
...status, COUNT(*) AS cnt from mytable...
Now the resultset would have an additional field named "cnt" which would contain the count.
:wave: