Private Function UniteDataTable(ByVal dt1 As DataTable, ByVal dt2 As DataTable, ByVal DTName As String)
        Dim dt3 As DataTable = dt1.Clone()
        For i As Short = 0 To dt2.Columns.Count - 1
            dt3.Columns.Add(dt2.Columns(i).ColumnName)
        Next
        Dim obj As New Object
        obj = dt3.Columns.Count
        For i As Short = 0 To dt1.Rows.Count - 1
            dt1.Rows(i).ItemArray.CopyTo(obj, 0)
            dt3.Rows.Add(obj)
        Next
        If dt1.Rows.Count >= dt2.Rows.Count Then
            For i As Short = 0 To dt2.Rows.Count - 1
                For j As Short = 0 To dt2.Columns.Count - 1
                    dt3.Rows(i)(j + dt1.Columns.Count) = dt2.Rows(i)(j).ToString()
                Next
            Next
        Else
            Dim dr3 As DataRow
            For i As Short = 0 To dt2.Rows.Count - dt1.Rows.Count - 1
                dr3 = dt3.NewRow()
                dt3.Rows.Add(dr3)
            Next
            For i As Short = 0 To dt2.Rows.Count - 1
                For j As Short = 0 To dt2.Columns.Count - 1
                    dt3.Rows(i)(j + dt1.Columns.Count) = dt2.Rows(i)(j).ToString()
                Next
            Next
        End If
        dt3.TableName = DTName
        Return dt3
    End Function

相关文章:

  • 2022-02-17
  • 2021-06-19
  • 2021-08-19
  • 2021-12-16
  • 2021-07-15
  • 2021-07-14
  • 2021-09-14
猜你喜欢
  • 2021-04-12
  • 2022-02-21
  • 2021-08-20
  • 2021-11-14
相关资源
相似解决方案