Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
下列代码可将“教师安排”列填充到“任课教师分析表”的“科目”和“教师”两列,请问如何修改下列代码,可将“班级”列一并填充?
Dim s As Date = Date.Now()
DataTables("任课教师分析").DataRows.Clear()
Dim Values() As String
Dim n As Integer = Tables("教师安排").rows.count
Dim n1 As Integer
for Each dc as Datacol in DataTables("教师安排").Datacols
if dc.name <> "班级" Then
n1 = n1 +1
dim f As New Filler
f.SourceTable = DataTables("教师安排") '指定数据来源
f.SourceCols = dc.name '指定数据来源列
f.DataTable = DataTables("任课教师分析") '指定数据接收表
f.DataCols = "教师" '指定数据接收列
f.Distinct = false
f.Fill() '填充数据
For i As integer = (n*n1)-n to Tables("任课教师分析").rows.count -1
Tables("任课教师分析").Rows(i)("科目") = dc.name
Tables("任课教师分析").Rows(i)("班级") = ?????
Next
end if
Next
Messagebox.Show("处理完毕! 耗时: " & (Date.Now -s).TotalSeconds)
原设计有两点不满意:一是速度太慢;二是填充后删除空值。原代码:
'填充"科目-班级-教师"3列数据
Dim s As Date = Date.Now()
DataTables("任课教师分析").DataRows.Clear
For j As Integer = 0 To 6
For i As Integer = 0 To 17
Dim r As Row = Tables("任课教师分析").AddNew
r("科目") = Tables("教师安排").Cols(j + 1).Name
r("班级") = i + 1
r("教师") = Tables("教师安排")(i,j + 1)
Next
Next
DataTables("任课教师分析").DeleteFor("[教师] Is Null")
相关表格:1、教师安排
f.SourceTable = DataTables("教师安排") '指定数据来源
f.SourceCols = "班级," & dc.name '指定数据来源列
f.DataTable = DataTables("任课教师分析") '指定数据接收表
f.DataCols = "班级,教师" '指定数据接收列
f.Distinct = false
f.Fill() '填充数据
出现错误提示
Dim s As Date = Date.Now()
DataTables("任课教师分析").DataRows.Clear()
Dim Values() As String
Dim n As Integer = Tables("教师安排").rows.count
Dim n1 As Integer
for Each dc as Datacol in DataTables("教师安排").Datacols
if dc.name <> "班级" Then
n1 = n1 +1
dim f As New Filler
f.SourceTable = DataTables("教师安排") '指定数据来源
f.SourceCols = dc.name & ",班级" '指定数据来源列
f.DataTable = DataTables("任课教师分析") '指定数据接收表
f.DataCols = "教师,班级" '指定数据接收列
f.Distinct = false
f.Fill() '填充数据
For i As integer = (n*n1)-n to Tables("任课教师分析").rows.count -1
Tables("任课教师分析").Rows(i)("科目") = dc.name
Next
end if
Next
Messagebox.Show("处理完毕! 耗时: " & (Date.Now -s).TotalSeconds)