03-12-21 05:58 AM
Answered! Go to Answer.
03-12-21 08:14 AM
Try
Output_Collection = Input_Collection.Copy
Dim Newcol As DataColumn = New DataColumn(Column_Name, GetType(String))
Output_Collection.Columns.Add(Newcol)
Output_Collection.Columns(Newcol.ColumnName.ToString).SetOrdinal(Column_Index)
Success = True
Catch ex As Exception
Message = ex.Message.ToString
Success = False
End Try
03-12-21 08:14 AM
Try
Output_Collection = Input_Collection.Copy
Dim Newcol As DataColumn = New DataColumn(Column_Name, GetType(String))
Output_Collection.Columns.Add(Newcol)
Output_Collection.Columns(Newcol.ColumnName.ToString).SetOrdinal(Column_Index)
Success = True
Catch ex As Exception
Message = ex.Message.ToString
Success = False
End Try
03-12-21 01:29 PM
03-12-21 03:04 PM
12-01-22 06:00 AM
12-01-22 02:00 PM
Dim columnCount As Integer = Input_Collection_Two.Columns.Count
Dim additionalRowCount As Integer = Math.Abs(Input_Collection_One.Rows.Count - Input_Collection_Two.Rows.Count)
If Column_Position > columnCount Then
Throw New Exception("The column position provided is out of range")
End If
If (additionalRowCount > 0 And Input_Collection_One.Rows.Count > Input_Collection_Two.Rows.Count) Then
For i As Integer = 1 To additionalRowCount
Dim newRow As DataRow = Input_Collection_Two.NewRow
Input_Collection_Two.Rows.Add(newRow)
Next
End If
For Each dc As DataColumn In Input_Collection_One.Columns()
Input_Collection_Two.Columns.Add(dc.ColumnName)
Input_Collection_Two.Columns(dc.ColumnName).SetOrdinal(Column_Position)
Column_Position = Column_Position+1
Next
Dim rowCounter As Integer = 0
For Each dr As DataRow In Input_Collection_One.Rows()
For Each dc As DataColumn In Input_Collection_One.Columns()
Input_Collection_Two.Rows(rowCounter).Item(dc.ColumnName) = Input_Collection_One.Rows(rowCounter).Item(dc.ColumnName)
Next
rowCounter += 1
Next
Output_Collection = Input_Collection_Two
12-01-22 02:10 PM
Dim columnCount As Integer = Input_Collection_Two.Columns.Count
Dim additionalRowCount As Integer = Math.Abs(Input_Collection_One.Rows.Count - Input_Collection_Two.Rows.Count)
If Column_Position > columnCount Then
Throw New Exception("The column position provided is out of range")
End If
If (additionalRowCount > 0 And Input_Collection_One.Rows.Count > Input_Collection_Two.Rows.Count) Then
For i As Integer = 1 To additionalRowCount
Dim newRow As DataRow = Input_Collection_Two.NewRow
Input_Collection_Two.Rows.Add(newRow)
Next
End If
Input_Collection_Two.Columns.Add(Column_Name)
Input_Collection_Two.Columns(Column_Name).SetOrdinal(Column_Position)
Dim rowCounter As Integer = 0
For Each dr As DataRow In Input_Collection_One.Rows()
Input_Collection_Two.Rows(rowCounter).Item(Column_Name) = Input_Collection_One.Rows(rowCounter).Item(Column_Name)
rowCounter += 1
Next
Output_Collection = Input_Collection_Two
13-01-22 07:13 AM
13-01-22 07:36 AM
31-03-22 04:39 PM
Hi Devneet ,
I tried this code and the problem is in the output .
The flag is shown true but the output collection is empty.
Where can be the problem ?
Thank ,
Erjola