Copying Data From a DataSet to another

Hey experts,

I need to make the RowState of all the rows of a certain DataSet "added", so I decided to add them one by one to a new DataSet, but apparently C# does not allow you to add to a new DataSet a row that already belongs to an existing one, I've tried tosolve this problem in more than 10 ways (by clearing the dataset, or putting the rows in an object array ...etc), but the problem remained the same........
The last way that I've tried to do it is as follows:

private DataSet RowInsertedDS(DataSet ds)
  DataSet ds2 = new DataSet();
  ds2 = ds.Clone();
  int count = ds.Tables[0].Rows.Count;
  ArrayList dr = new ArrayList();
  for(int i=0;i<count;i++)
  Object[] dr2 = new Object[count];
  for(int i=0;i<dr2.Length;i++)
  return ds2;

The problem still occured (in the code above) in the before last line of code (inside the last for loop)....any help on solving the problem??

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Look at the DataTable.ImportRow method instead.

mte01Author Commented:
The method copied the rows msuccessfully into the new dataset, but the STATE of the rows remained unchanged (and not  inserted).
mte01Author Commented:
Problem Solved:

When setting the property AcceptChangesDuringFill to false in SqlDataAdapter, the state of the rows when filling a dataset becomes added (and not unchanged)....
Closed, 275 points refunded.
Friendly Neighbourhood Community Support Admin

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.