|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cloning Datasets but also filteringI 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 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 "Daren Hawes" <newsgro***@webdesignmagic.com.au> wrote in A dataview will do it without copying it.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? -- 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 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 >
Operator '=' on System.DateTime and System.Double
sqltransaction Trying to find ClientID of web form - Update System.InvalidOperationException: ExecuteReader from mm/dd/yyyy to yyyy/mm/dd Displaying many-to-many relation data in dataGrids Trying to find ClientID of web form DataColumn.Expression complex calculations RETURNING INTO returns ORA-01036: illegal variable name/number C# to SQL Server 2000 datatype mappings |
|||||||||||||||||||||||