PC Review


Reply
Thread Tools Rate Thread

Cloning Datasets but also filtering

 
 
Daren Hawes
Guest
Posts: n/a
 
      21st Jun 2005
Hi,

I have 2 Datasets with 20 tables.

Ones called Surveys and the other SingleSurveys.

Surveys contains ALL survey data (IE SurveyID = 1,2,3,4,5......). All
tables have related ID field (IE SurveyID on each table)

I need to copy over to SingleSurveys only one survey data (IE SurveyID = 12)

The SingleSurvey should contain all the same tables, but filtered fields by
the SurveyID.

Is there a fast way to do this? Dataviews?

I have investigated some components but the seem to put all the data in 1
table. I need the same structure just data pertaining to a certain
surveyID?

Thanks Daren


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      21st Jun 2005
Daren,

This is a quickly in this message made sample that would do the job in my
idea. However watch typos or what so ever.

\\\
DataTable dt = MyFirstDatatable.Tables("Whatever");
DataView dv = new DataView(dt);
dv.RowFilter = "MyCriteria = Whatever";
DataTable dtnew = dt.Clone();
foreach (DataRowView dvr in dv)
dtnew.ImportRow(dvr.Row);
dt.Clear();
MyOtherDataset.Tables.Add(dtnew);
///

I hope this helps,

Cor


 
Reply With Quote
 
Chad Z. Hower aka Kudzu
Guest
Posts: n/a
 
      21st Jun 2005
"Daren Hawes" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):
> The SingleSurvey should contain all the same tables, but filtered
> fields by the SurveyID.
>
> Is there a fast way to do this? Dataviews?


A dataview will do it without copying it.



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu
 
Reply With Quote
 
Adrian Moore
Guest
Posts: n/a
 
      21st Jun 2005
Daren,

You might be interested in the assembly I've been working on at
http://www.queryadataset.com. It lets you perform complex SQL SELECT
statements including UNION, JOINS, GROUP BY, HAVING, ORDER BY, sub-queries,
etc against the tables in a dataset. It also supports SELECT INTO. In your
case you could issue the following query against the Surveys DataSet.

SELECT * INTO [table name] FROM [table name] WHERE SurveyID=12

The table name in the INTO clause can be the same name as the FROM clause.
INTO simply sets the name of the DataTable being returned in the DataView.
This table can be added to your SingleSurveys DataSet. This is a great way
to create a filtered clone of a DataSet.

I know I've offered you help before and you might have visited the web-site
previously. However, its been updated and there is now a demo download you
can try.

Hope this helps
Adrian Moore
http://www.queryadataset.com


"Daren Hawes" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have 2 Datasets with 20 tables.
>
> Ones called Surveys and the other SingleSurveys.
>
> Surveys contains ALL survey data (IE SurveyID = 1,2,3,4,5......). All
> tables have related ID field (IE SurveyID on each table)
>
> I need to copy over to SingleSurveys only one survey data (IE SurveyID =
> 12)
>
> The SingleSurvey should contain all the same tables, but filtered fields
> by the SurveyID.
>
> Is there a fast way to do this? Dataviews?
>
> I have investigated some components but the seem to put all the data in 1
> table. I need the same structure just data pertaining to a certain
> surveyID?
>
> Thanks Daren
>



 
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
Datasets - Cloning problems =?Utf-8?B?UCBL?= Microsoft ASP .NET 3 31st Mar 2006 10:49 PM
Pre-filtering datasets Sam Microsoft ADO .NET 2 13th Mar 2006 10:59 PM
Filtering Datasets JJBean Microsoft C# .NET 1 11th Jan 2004 01:14 AM
Filtering Datasets JJBean Microsoft C# .NET 1 10th Jan 2004 10:44 PM
Filtering / comparind datasets Zachary Heilman Microsoft ADO .NET 1 7th Nov 2003 05:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:31 PM.