Results 1 to 10 of 10

Thread: [RESOLVED] Help with Copying Datarow

Threaded View

  1. #1

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Resolved [RESOLVED] Help with Copying Datarow

    hi guys help please.
    Currently i have a code below that Supposedly copy the structure of the Dataset "ds" to Dataset "tmpds" and perform a logical test and if it is true a Datarow from Table1 of "ds" Dataset will be copied or Add to Table1 of "tmpds" Dataset but it has an error (See the Code in Bold letters)

    CODE:
    Code:
            DataSet FuncTrimValidity(DataSet ds)
            {
                DataSet tmpds = ds.Clone();
                DataRow dr;// = new DataRow();
                try
                {      
                    //My logical test here if if it is true perform the code below
                    //IF(My logic Test){ //But this does not matter to my question
                    dr = ds.Tables[1].Rows[0];
                    tmpds.Tables[1].Rows.Add(dr); //Error Occurs Here
                    //}
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                return tmpds;
            }
    ERROR:
    "This row already belongs to another table."
    Any suggestion guys to solve the problem? Thanks in advance!
    Last edited by daimous; Aug 21st, 2007 at 03:49 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width