Home
Manage Your Code
Snippet: student exam rank (VB.NET)
Title: student exam rank Language: VB.NET
Description: student exam rank Views: 327
Author: Sandesh Maharjan Date Added: 7/25/2012
Copy Code  
1 Private Sub ExamRank()
2        Try
3            Dim sql As String = _
4       "SELECT student,dense_rank() OVER (ORDER BY percentage DESC) as 'Rank' " & _
5       "FROM examresult " & _
6       "WHERE acayear='" & academic_year & "' and gcode='" & cmbGrp.SelectedValue & "' and exam='" & cmbTerm.SelectedValue & "' and examtype='1'"
7            Dim dt As DataTable = SchoolDB.GetDataTable(sql)
8            If Not dt Is Nothing And dt.Rows.Count > 0 Then
9                For Each row As DataRow In dt.Rows
10                    Dim stid As String = row.Item("student")
11                    Dim rank As String = row.Item("rank")
12                    'update rank

13                    sql = "UPDATE examresult SET rank='" & rank & "' " & _
14                    "WHERE student='" & stid & "' and acayear='" & academic_year & "' and gcode='" & cmbGrp.SelectedValue & "' and exam='" & cmbTerm.SelectedValue & "' and examtype='1'"
15                    dt = SchoolDB.GetDataTable(sql)
16                Next
17            End If
18            'MsgBox("", MsgBoxStyle.Information)

19        Catch ex As Exception
20
21        End Try
22       
23
24    End Sub