Home All Groups Group Topic Archive Search About

Cloning Datasets but also filtering

Author
21 Jun 2005 3:39 AM
Daren Hawes

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
Author
21 Jun 2005 7:58 AM
Cor Ligthert
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
Are all your drivers up to date? click for free checkup

Author
21 Jun 2005 10:10 AM
Chad Z. Hower aka Kudzu
"Daren Hawes" <newsgro***@webdesignmagic.com.au> wrote in
news:e14NYMhdFHA.3932@TK2MSFTNGP12.phx.gbl:
> 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
Author
21 Jun 2005 12:28 PM
Adrian Moore
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


Show quoteHide quote
"Daren Hawes" <newsgro***@webdesignmagic.com.au> wrote in message
news:e14NYMhdFHA.3932@TK2MSFTNGP12.phx.gbl...
> 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
>

Bookmark and Share