1st make the clone of the datatable inside dataset

e.g DataTable dt = DataSet.Table[0].Clone();

by cloning the stucture of the datatable will be same..

now make foreach loop on the dataset

foreach DataRow dr in Ds.Tables[0].Row
{
DataRow drNew = dt.NewRow();
drNew[ColumnIndex]=dr[ColumnIndex];
.
.
.
dt.Rows.Add(drNew);

}

then add this datatable to the new dataset object

dsNew.Tables.Add(dt);

Hope thats help.






On Wed, Nov 12, 2008 at 2:45 PM, Benj Nunez <[EMAIL PROTECTED]> wrote:

>
> Hello experts,
>
> Currently I'm stuck in a situation in which I need to copy a record
> from one dataset
> to another. Can anyone help me out with this?
>
> My goal is to loop through a dataset and check if a certain field
> meets a criterion,
> if there's a match, that record goes through another dataset. Here's
> what my code looks like:
>
>  DataSet dsRenewal  = new DataSet();
>  DataSet dsNewActive    = new DataSet();
> ...
>
>  foreach (DataRow dr in ds.Tables["TBL_MFQueryResult"].Rows)
>  {
>     if (dr["MF_TYPE"] == '0')       //  '0' means its a renewal, '1'
> New Active and so on...
>     {
>       dsRenewal.Tables[0].Add(ds.Tables["TBL_MFQueryResult"].Rows
> [?].ItemArray);  // huh?
>     }
>    else if (dr[...])
>    {
>      dsNewActive.Tables[]....
>    }
>   ...
>
>  }
>
>
> Cheers!
>
>
> Benj
>
>
>
>


-- 
Muhammad Arif
Software Engineer
+923009347315

Reply via email to