You will need to manually do any custom merge such as your example.
What should the follow result be?
[quoted text, click to view] > Table A (Main Table)
>
> Id: C2: C3
> 01 null 30
> 02 50 null
>
> Table B (Source Table)
>
> Id: C2: C3
> 01 50 null
> 02 null 30
Assuming that Id is the primary key of both tables, I would use a loop
similar to (untested):
Dim mainTable As New DataTable("Main Table")
mainTable.Columns.Add("Id", GetType(Integer))
mainTable.Columns.Add("C2", GetType(Integer))
mainTable.Columns.Add("C3", GetType(Integer))
mainTable.PrimaryKey = New DataColumn() {mainTable.Columns("Id")}
mainTable.Rows.Add(New Object() {1, DBNull.Value, 30})
mainTable.Rows.Add(New Object() {2, DBNull.Value, 30})
Dim sourceTable As New DataTable("Source Table")
sourceTable.Columns.Add("Id", GetType(Integer))
sourceTable.Columns.Add("C2", GetType(Integer))
sourceTable.Columns.Add("C3", GetType(Integer))
sourceTable.PrimaryKey = New DataColumn()
{sourceTable.Columns("Id")}
sourceTable.Rows.Add(New Object() {1, 50, DBNull.Value})
sourceTable.Rows.Add(New Object() {2, 50, DBNull.Value})
For Each mainRow As DataRow In mainTable.Rows
Dim sourceRow As DataRow = sourceTable.Rows.Find(mainRow!Id)
For Each mainColumn As DataColumn In mainTable.Columns
Dim sourceColumn As DataColumn =
sourceTable.Columns(mainColumn.ColumnName)
If mainRow.IsNull(mainColumn) Then
mainRow(mainColumn) = sourceRow(sourceColumn)
' Next two lines are optional if you want the source
table updated
'ElseIf sourceRow.IsNull(sourceColumn) Then
' sourceRow(sourceColumn) = mainRow(mainColumn)
End If
Next
Next
Hope this helps
Jay
[quoted text, click to view] <yachea2002@hotmail.com> wrote in message
news:f42f8d60.0407301313.77a129ce@posting.google.com...
> Hi, I am trying to merge a Dataset with author one that contains some
> null column values.
>
> Ex:
>
> Table A (Main Table)
>
> Id: C2: C3
> 01 null 30
> 02 null 30
>
> Table B (Source Table)
>
> Id: C2: C3
> 01 50 null
> 02 50 null
>
>
> When I try A.merge(B) this is what I get:
>
> Table A (Main Table)
>
> Id: C2: C3
> 01 50 null
> 02 50 null
>
> Could any one tell me how to do to get this result? :
>
> Table A (In the main Table)
>
> Id: C2: C3
> 01 50 30
> 02 50 30
>
> Thanks a lot.