解决方案1:
Dim i As Integer = CInt(_table.Rows(0).Item(3))
Do While i - 2 > 0
_tableBackLogs.Merge(Global.DataAccess.GetDataTable("SELECT SubjectID,SubjectName,Grade FROM SubjectPI WHERE RegNo='" & CInt(HttpContext.Current.Session("userName")) & "' AND Status='Fail' AND Semester='" & i - 2 & "'"))
i = i - 2
Loop
溶液 2:
If i = 1 Then
Global.DataAccess.GetDataTable("SELECT SubjectID,SubjectName,Grade FROM SubjectPI WHERE RegNo='" & CInt(HttpContext.Current.Session("userName")) & "' AND Status='Fail' AND Semester='" & i & "'")
ElseIf i = 2 Then
Global.DataAccess.GetDataTable("SELECT SubjectID,SubjectName,Grade FROM SubjectPI WHERE RegNo='" & CInt(HttpContext.Current.Session("userName")) & "' AND Status='Fail' AND Semester='" & i - 2 & "'")
ElseIf i = 3 Then
Global.DataAccess.GetDataTable("SELECT SubjectID,SubjectName,Grade FROM SubjectPI WHERE RegNo='" & CInt(HttpContext.Current.Session("userName")) & "' AND Status='Fail' AND Semester='" & i - 2 & "'")
'On and on....upto i=8
End If
就性能和执行速度而言,哪一个是更好的解决方案?
更新:我将数据存储到数据表中......然后将其与 ListView 一起使用。