Home All Groups Group Topic Archive Search About

Appending two data tables

Author
1 May 2006 8:22 PM
Mark
Hi -

I'm looking for a code sample that will let me append a data table to a
second master data table. You can assume that the tables' structures are
identical.

Seems like there should be a method to do this, but I can't find one.

Thanks,
Mark

Author
1 May 2006 8:47 PM
Cor Ligthert [MVP]
Mark,

DataTable.Merge

http://msdn2.microsoft.com/en-us/library/system.data.datatable.merge.aspx

Be aware that this works conform the constrains of that datatable, therefore
adding will only be if the keys of the new one are really different and
higher than the old one.

I hope this helps,

Cor


Show quoteHide quote
"Mark" <M***@discussions.microsoft.com> schreef in bericht
news:1D4BCA7E-38D9-412C-B549-C05FA7681BBA@microsoft.com...
> Hi -
>
> I'm looking for a code sample that will let me append a data table to a
> second master data table. You can assume that the tables' structures are
> identical.
>
> Seems like there should be a method to do this, but I can't find one.
>
> Thanks,
> Mark
>
Author
2 May 2006 5:48 PM
Mark
Merge works for .NET Framework 2.0.  (I'm running 1.0)

I used the ImportRow method:

For i = 0 to dt.rows.count - 1
      dtMain.ImportRow(dt.Rows(i))
next i


Thanks for your comments





Show quoteHide quote
"Cor Ligthert [MVP]" wrote:

> Mark,
>
> DataTable.Merge
>
> http://msdn2.microsoft.com/en-us/library/system.data.datatable.merge.aspx
>
> Be aware that this works conform the constrains of that datatable, therefore
> adding will only be if the keys of the new one are really different and
> higher than the old one.
>
> I hope this helps,
>
> Cor
>
>
> "Mark" <M***@discussions.microsoft.com> schreef in bericht
> news:1D4BCA7E-38D9-412C-B549-C05FA7681BBA@microsoft.com...
> > Hi -
> >
> > I'm looking for a code sample that will let me append a data table to a
> > second master data table. You can assume that the tables' structures are
> > identical.
> >
> > Seems like there should be a method to do this, but I can't find one.
> >
> > Thanks,
> > Mark
> >
>
>
>