0

I have to copy rows from one table to another. In the source table I can have RowError set on rows. When I do this:

targetTable.BeginLoadData();
targetTable.Load( new DataTableReader( sourceTable ) )
targetTable.EndLoadData();

The target table does not get row errors copied on its rows from source table. Can anyone tell what am I supposed to do to make it work? Thanks.

EDIT: I do not want to lose the data already present in the target table. Nor do I want to change the reference.

user1004959
  • 627
  • 6
  • 16

1 Answers1

1

Try this:

targetTable = sourceTable.Copy();

Creating a reader won't give you the expected result in this case, because its (reader) goal will be extracting the value of each row, not the appendant properties.

Update:

In this case, you should:

foreach (DataRow drImport in sourceTable.Rows) {
    targetTable.ImportRow(drImport);
}

Sorry, just before posting I've seen your other observation about the reference. I'm afraid you can't have the same row (same reference) assigned to two ore more tables. See this.

Community
  • 1
  • 1
J.Hudler
  • 1,238
  • 9
  • 26
  • Maybe I was not clear in my question. I do not want to lose the data already present in the target table. Nor do I want to change the reference. `targetTable` is referencing a DataTable in memory which is also being referenced by other components in my application. – user1004959 Jul 09 '12 at 07:20
  • I meant reference of `targetTable`, not the rows. :) – user1004959 Jul 11 '12 at 09:51