Click here to Skip to main content
15,749,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello good people. Am having trouble to display records on a listview in vb6. Here is the scenario am having.
I have this table:

sId SName sCourse sMark
1 Amos COS 110 50
2 John COS 110 60
3 Amos COS 210 70

i wish to display it as:
sId sName COS110 COS210
1 Amos 50 70
2 John 60 0

Please help its urgent. Thanx

#realJSOP 28-Sep-10 7:47am    
It's not urgent for anyone but you.

Try use to group by on sCourse column and also using case statement.
Share this answer
amosndungu 28-Sep-10 8:15am    
how could the sample query be? with this code below, i have achieved to display the courses and the first mark but the subsequent marks wont show up. here
With lsvConsolidatedMark
Set colx = .ColumnHeaders.Add(, , ("Registration No."), colWidth)
Set colx = .ColumnHeaders.Add(, , ("Student Name"), colWidth)

Do While Not rs.EOF()
cosCod = rs!coursecode
Set colx = .ColumnHeaders.Add(, , (cosCod), colWidth)
End With

'adding rows to listview
With lsvConsolidatedMark
If rs.RecordCount > 0 Then
While Not rs.EOF()
reg = rs!regno
studNam = rs!studentName
mak = rs!mark
Set listitem = .ListItems.Add(, , (rs!regno))
listitem.SubItems(1) = rs!studentName
On Error Resume Next
Do While Not rs.EOF()
listitem.SubItems(2) = mak
End If
End With
amosndungu 28-Sep-10 8:18am    
am using this query:
strSQL = "SELECT * FROM tblexamcdmha where program='" & Me.lblProgramme.Caption & "' and" _
& " yearOfStudy ='" & Me.lblYearOfStudy.Caption & "' and" _
& " academicYear ='" & Me.lblAcademicYear.Caption & "'and" _
& " combinations ='" & Me.lblCombination.Caption & "'"
Asuming you are using SQL server try read some about Pivot[^].
Share this answer
amosndungu 28-Sep-10 8:16am    
Am using mysql!
Goutam Patra 28-Sep-10 8:33am    
I am not very sure sut take a look at

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900