I would rather do it this way :

---
DataTable dt = ds.Tables["TBL_MFQueryResult"];
DataView dv = dt.DefaultView;

// Filter the view according the value in the MF_TYPE column.
// You only require the single quotes if the column is a char Sql
Type.
dv.RowFilter = "MF_TYPE = '0'";
DataTable dtRenewal = dv.ToTable("Renewal");

// Filter the view according the value in the MF_TYPE column.
dv.RowFilter = "MF_TYPE = '1'";
DataTable dtNewActive = dv.ToTable("New Active");

---

If you must do it your way, you already have the reference to the
required DataRow in your For-Each block, so why do you need to
reference it from the DataTable ?

---
dsRenewal.Tables[0].Add(dr.ItemArray);
---

On Nov 12, 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

Reply via email to