Re: copy datatable
From: Peter Foot [MVP] (feedback_at_nospam-inthehand.com)
Date: 03/18/05
- Next message: Glyn Meek: "Re: OpenNetCF expectation"
- Previous message: maluman: "Re: WaitCursor shows only for a moment"
- In reply to: Sitar: "copy datatable"
- Next in thread: Fred Hirschfeld: "Re: copy datatable"
- Reply: Fred Hirschfeld: "Re: copy datatable"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Mar 2005 13:08:42 -0000
I'm not sure if it will improve performance in your example (depends on the
constraints you have set up), but you could call dtCopy.BeginLoadData and
EndLoadData around your insertions e.g.
dtCopy.BeginLoadData();
foreach(DataRow dr in dtOriginal.Rows)
{
dtCopy.ImportRow(dr);
}
dt.Copy.EndLoadData();
Peter
-- Peter Foot Windows Embedded MVP http://www.inthehand.com | http://blog.opennetcf.org/pfoot/ "Sitar" <Sitar@discussions.microsoft.com> wrote in message news:8D2ED9CD-3E2F-4D74-9B33-5853633542FC@microsoft.com... > Hi, > > In my quest for performance, I come up with another question... > There is no DataTable.Copy() with CF and I need to do that. So I came up > with my own implementation which is as follow: > > public static DataTable DataTableCopy(DataTable dtOriginal) > { > DataTable dtCopy = dtOriginal.Clone(); > try > { > for (int j=0;j<dtOriginal.Rows.Count;j++) > { > dtCopy.ImportRow(dtOriginal.Rows[j]); > } > } > catch(Exception ex) > { > throw new System.Exception("Datatable copy error", ex); > } > > return dtCopy; > } > > I'm wondering if it is the fastest way to do it though. I use ImportRow > because I need to preserve the RowState values. > > Any comment on this? > > Thanks, > Sitar. >
- Next message: Glyn Meek: "Re: OpenNetCF expectation"
- Previous message: maluman: "Re: WaitCursor shows only for a moment"
- In reply to: Sitar: "copy datatable"
- Next in thread: Fred Hirschfeld: "Re: copy datatable"
- Reply: Fred Hirschfeld: "Re: copy datatable"
- Messages sorted by: [ date ] [ thread ]
Loading