Dim ksmc As String = e.Form.Controls("combobox1").text
If ksmc > ""
Dim dt As DataTable = DataTables("成绩")
Dim qArys As List(Of String()) = dt.GetValues("考试名称|年级代码")
If js.Contains("区业务主管")
For Each qAry As String() In qArys
Dim drs As List(Of DataRow) = dt.S elect("[考试名称] = '" & qary(0) & "'And [年级代码] ='" & qary(1) & "' and 学段 ='初中'", "折总 DESC")
For n As Integer = 0 To drs.Count - 1 '遍历所有行
If n > 0 AndAlso drs(n)("折总") = drs(n-1)("折总") Then '如果总分和上一行相同
drs(n)("区序") = drs(n-1)("区序") '则排名等于上一行
Else
drs(n)("区序") = n + 1 '设置排名
End If
Next
Next
For Each qAry As String() In qArys
Dim drs1 As List(Of DataRow) = dt.Sele ct("[考试名称] = '" & qary(0) & "'And [年级代码] ='" & qary(1) & "'and 学段='初中'", "总分 DESC")
For n As Integer = 0 To drs1.Count - 1 '遍历所有行
If n > 0 AndAlso drs1(n)("总分") = drs1(n-1)("总分") Then '如果总分和上一行相同
drs1(n)("总分区序") = drs1(n-1)("总分区序") '则排名等于上一行
Else
drs1(n)("总分区序") = n + 1 '设置排名
End If
Next
Next
End If
Dim Arys As List(Of String()) = dt.GetValues("考试名称|单位名称|年级代码")
For Each Ary As String() In Arys
Dim drs As List(Of DataRow) = dt.Select("[考试名称] = '" & ary(0) & "'And [单位名称] = '" & ary(1) & "'and [年级代码] ='" & ary(2) & "'and 学段='初中'", "折总 DESC")
For n As Integer = 0 To drs.Count - 1 '遍历所有行
If n > 0 AndAlso drs(n)("折总") = drs(n-1)("折总") Then '如果总分和上一行相同
drs(n)("校序") = drs(n-1)("校序") '则排名等于上一行
Else
drs(n)("校序") = n + 1 '设置排名
End If
Next
Next
For Each Ary As String() In Arys
Dim drs As List(Of DataRow) = dt.Sele ct("[考试名称] = '" & ary(0) & "'And [单位名称] = '" & ary(1) & "'and [年级代码] ='" & ary(2) & "'and 学段 = '初中'", "总分 DESC")
For n As Integer = 0 To drs.Count - 1 '遍历所有行
If n > 0 AndAlso drs(n)("总分") = drs(n-1)("总分") Then '如果总分和上一行相同
drs(n)("总分校序") = drs(n-1)("总分校序") '则排名等于上一行
Else
drs(n)("总分校序") = n + 1 '设置排名
End If
Next
Next
Dim Arys1 As List(Of String()) = dt.GetValues("考试名称|单位名称|年级代码|班级")
For Each Ary1 As String() In Arys1
Dim drs As List(Of DataRow) = dt.Se lect("[考试名称] = '" & ary1(0) & "'And [单位名称] = '" & ary1(1) & "'and [年级代码] ='" & ary1(2) & "'And [班级] = '" & ary1(3) & "'and 学段='初中'", "折总 DESC")
For m As Integer = 0 To drs.Count - 1 '遍历所有行
If m > 0 AndAlso drs(m)("折总") = drs(m-1)("折总") Then '如果总分和上一行相同
drs(m)("班序") = drs(m-1)("班序") '则排名等于上一行
Else
drs(m)("班序") = m + 1 '设置排名
End If
Next
Next
For Each Ary1 As String() In Arys1
Dim drs As List(Of DataRow) = dt.Sel ect("[考试名称] = '" & ary1(0) & "'And [单位名称] = '" & ary1(1) & "'and [年级代码] ='" & ary1(2) & "'And [班级] = '" & ary1(3) & "'and 学段='初中'", "总分 DESC")
For m As Integer = 0 To drs.Count - 1 '遍历所有行
If m > 0 AndAlso drs(m)("总分") = drs(m-1)("总分") Then '如果总分和上一行相同
drs(m)("总分班序") = drs(m-1)("总分班序") '则排名等于上一行
Else
drs(m)("总分班序") = m + 1 '设置排名
End If
Next
Next
Dim strlist As List(Of String) = Functions.Execute("sql提取函数",Tables("成绩"),"成绩","_Identify","[_Identify]","班序|校序|区序|总分班序|总分校序|总分区序","班序|校序|区序|总分班序|总分校序|总分区序",1)
Dim sql As String
Dim cmd As New SQLCommand
cmd.C
Dim Count As Integer = 0
try
Connections").BeginTransaction
For Each s As String In strlist
cmd.CommandText = s
Count += cmd.ExecuteNonQuery()
Next
Connections").Commit '提交事务,所有操作生效
Catch ex As Exception '如果出错
msgbox(ex.message)
Connections(").Rollback() '回滚事务,撤销所有操作
End Try
Tables("成绩").DataTable.BaseTable.AcceptChanges() '提交修改
Else
messagebox.show("请选择要排的考试名称","提示")
End If
老师,为进行后台数据排序,为提高速度,我采取加载后排序再用sql提取保存,但还是很慢,5000左右记录要等一分钟左右,有什么办法直接进行后台排序,sqlreplacefor 写入排序结果