I think you are a bit confused, at least the code is confused. What you have
in code clones a datatable and filters it to a subset of rows. Then, source
dataset is cleared which also clears the target dataset because the
dt.select statement actually is a shallow copy/reference assignment and not
a true deep copy. Then you turn around and add the empty datarow objects
back into the cleared datatable. I'm certain that this is not what you want
to do. Otherwise, i'm confused.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
"byrd48" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> am attempting to create a DataTable by copying a table from a data
> set, then filter the rows as follows:
>
> DataTable dt = DataSet1.Tables[0].Copy;
>
> DataRow[] dr = dt.Select("myexpression");
>
> dt.Rows.Clear();
>
> dt.Rows.Add(dr);
>
> I have validated that teh number of columns in the datatable matches
> the number of items in the DataRow.ItemArray, but it still throws an
> exception on the last line that the index of dr is greater than the
> number of columns in the datatable.
> Thanks in advance,
>
> Jon
>