老师好怎样在数据源中把三个表合并到另外一个表中,字段是不一样的。
老师,下面代码怎样优化。
Dim Cols1() As String = {"第一列","第二列","第三列"}
Dim Cols2() As String = {"第一列","第二列","第三列"}
For Each dr1 As DataRow In DataTables("表A").Select("")
Dim dr2 As DataRow = DataTables("接收表").AddNew()
For i As Integer = 0 To Cols1.Length -1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
Next
Dim Cols3() As String = {"名称","金额","数量"}
Dim Cols4() As String = {"第四列","第五列","第六列"}
For Each dr3 As DataRow In DataTables("表B").Select("[金额] > 0")
Dim dr4 As DataRow = DataTables("接收表").AddNew()
For i As Integer = 0 To Cols3.Length -1
dr4(Cols4(i)) = dr3(Cols3(i))
Next
Next
使用find查询一下接收表,如果有对应的数据就不再添加