Click here to Skip to main content
15,885,985 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

Amos
Posted
Comments
#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
 
Comments
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
.ColumnHeaders.Clear
Set colx = .ColumnHeaders.Add(, , ("Registration No."), colWidth)
Set colx = .ColumnHeaders.Add(, , ("Student Name"), colWidth)
rs.MoveFirst

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

'adding rows to listview
With lsvConsolidatedMark
.ListItems.Clear
If rs.RecordCount > 0 Then
rs.MoveFirst
While Not rs.EOF()
reg = rs!regno
studNam = rs!studentName
mak = rs!mark
Set listitem = .ListItems.Add(, , (rs!regno))
listitem.SubItems(1) = rs!studentName
rs.MoveFirst
On Error Resume Next
Do While Not rs.EOF()
listitem.SubItems(2) = mak
listitem.sub
rs.MoveNext
Loop
rs.MoveNext
Wend
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
 
Comments
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
http://stackoverflow.com/questions/649802/how-to-pivot-a-mysql-entity-attribute-value-schema

http://search.mysql.com/search/query/search?q=pivot&group=refman-50

http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html

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