Dim ksmc As String = e.Form.Controls("combobox1").text
If ksmc > ""
Dim dt As DataTable = DataTables("成绩")
Dim qArys As List(Of String()) = dt.GetValues("考试名称|年级代码")
Dim st1 As Date = Date.Now
If js.Contains("区业务主管")
For Each qAry As String() In qArys
Dim drs As List(Of DataRow) = dt.S e lect("[考试名称] = '" & 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.Se lec t("[考试名称] = '" & 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.Sel e 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
For Each Ary As String() In Arys
Dim drs As List(Of DataRow) = dt.Se le 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.Select("[考试名称] = '" & 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.Se le ct("[考试名称] = '" & 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
MessageBox.Show("亲,我正在为节省您的每一秒钟努力,本次保存共耗时: " & (Date.Now - st1).TotalSeconds & "秒")
For Each r As Row In Tables("初中明细_table1")
DataTables("成绩").SQLReplaceFor("班序", r("班序"), "[_Identify] = '" & r("_Identify") & "'")
DataTables("成绩").SQLReplaceFor("校序", r("校序") ,"[_Identify] = '" & r("_Identify") & "'")
DataTables("成绩").SQLReplaceFor("区序", r("区序") ,"[_Identify] = '" & r("_Identify") & "'")
DataTables("成绩").SQLReplaceFor("总分班序", r("总分班序"), "[_Identify] = '" & r("_Identify") & "'")
DataTables("成绩").SQLReplaceFor("总分校序", r("总分校序"), "[_Identify] = '" & r("_Identify") & "'")
DataTables("成绩").SQLReplaceFor("总分区序", r("总分区序"), "[_Identify] = '" & r("_Identify") & "'")
Next
DataTables("成绩").load
Else
messagebox.show("请选择要排的考试名称","提示")
End If
老师,因为一次考试有2万个记录,加载出来排序,因为有6列排序,排好后用save保存要花很多时间,用sql提取保存也很久,我想用sqlreplacefor的办法结果简直一直等,请老师帮忙看一下如何做更高效,一二十秒能搞定也好嘛