PC Review


Reply
Thread Tools Rate Thread

DataTable Copy best practice question

 
 
Bill
Guest
Posts: n/a
 
      12th Mar 2004

I use Remoting in my WinForms applications and my forms
usually call some type of GetInitData method of the
Business component that returns a DataSet. The
GetInitData method usually calls classes from my Data
component to populate drop down lists on the form. For
example: Teacher, Subject, ...

The Data components usually have a GetList function which
calls a stored proc and returns a DataTable.

In my Business component, I usually end up adding my
DataTables to one DataSet. It seems like a clean
business function interface this way.

OK, here's the question: Is there another way to add a
DataTable to a DataSet other than using the Copy()
method? Since the DataTables have belonged to another
DataSet via the DataAdapter.Fill, exceptions occur when
using the DataSet.Tables.Add(). I'm concerned with the
performance and memory hit by using Copy().

Thanks in advance for your input,
Bill


 
Reply With Quote
 
 
 
 
Cor
Guest
Posts: n/a
 
      13th Mar 2004
Hi Bill,

> OK, here's the question: Is there another way to add a
> DataTable to a DataSet other than using the Copy()
> method? Since the DataTables have belonged to another
> DataSet via the DataAdapter.Fill, exceptions occur when
> using the DataSet.Tables.Add(). I'm concerned with the
> performance and memory hit by using Copy().


A lot, but when you can use the copy, there will be probably not one which
is more efficient.

Just my thougt,

Cor


 
Reply With Quote
 
Ravi[MSFT]
Guest
Posts: n/a
 
      17th Mar 2004
The right question to ask is whether you really need the datatable [with
same schema and data] as part of two datasets.

If you do not need the datatable to be part of two datasets, remove the
datatable from one dataset with ds.Tables.Remove and add it to the dataset
where you want it to be.

However, if you want the table to be present in both the datasets, then
datatable.Copy() is the right method to call before inserting it into other
datatable.

HTH,
Ravi

"Bill" <(E-Mail Removed)> wrote in message
news:bf7101c40864$fb48caa0$(E-Mail Removed)...
>
> I use Remoting in my WinForms applications and my forms
> usually call some type of GetInitData method of the
> Business component that returns a DataSet. The
> GetInitData method usually calls classes from my Data
> component to populate drop down lists on the form. For
> example: Teacher, Subject, ...
>
> The Data components usually have a GetList function which
> calls a stored proc and returns a DataTable.
>
> In my Business component, I usually end up adding my
> DataTables to one DataSet. It seems like a clean
> business function interface this way.
>
> OK, here's the question: Is there another way to add a
> DataTable to a DataSet other than using the Copy()
> method? Since the DataTables have belonged to another
> DataSet via the DataAdapter.Fill, exceptions occur when
> using the DataSet.Tables.Add(). I'm concerned with the
> performance and memory hit by using Copy().
>
> Thanks in advance for your input,
> Bill
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating DataTable best practice question Jon Pope Microsoft ADO .NET 1 15th Jun 2007 08:14 PM
Copy just some rows from a datatable to another datatable. UJ Microsoft ADO .NET 3 3rd Jan 2006 09:41 AM
Best practice for DataSet/DataTable use w/several forms =?Utf-8?B?Um9tYW8=?= Microsoft C# .NET 1 16th Aug 2005 08:18 PM
Difference between DataTable.Clone ( ) and DataTable.Copy ( ) ? Gordian Microsoft ADO .NET 2 28th Jul 2005 08:14 PM
Clone DataTable or Copy DataTable Problem Kelvin Microsoft C# .NET 0 13th Dec 2004 07:55 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:18 PM.