我的代码如下:
Dim dtb As New DataTableBuilder("表B")
dtb.AddDef("试样编号", Gettype(String), 32)
dtb.AddDef("fid", Gettype(String), 32)
For Each v As String In DataTables("检测记录明细").GetValues("参数名称")
dtb.AddDef(v & "_值" , Gettype(String),50)
dtb.AddDef(v & "_标准值" , Gettype(String),50)
Next
dtb.Build()
For Each v As String() In DataTables("检测记录明细").GetValues("Fid|试样编号")
Dim dr1 As DataRow = DataTables("表B").AddNew()
dr1("Fid")= v(0)
dr1("试样编号") = v(1)
For Each dr2 As DataRow In DataTables("检测记录明细").Select("[试样编号] = '" & v(1) & "'and [fid] = '" & v(0) & "'")
dr1(dr2(v & "_值")) = dr2("字符值")
dr1(dr2(v & "_标准值")) = dr2("标准值")
Next
Next
MainTable = Tables("表B")