Results 1 to 4 of 4

Thread: Cloning datarow in .net

  1. #1
    Join Date
    Apr 2008
    Posts
    242

    Cloning datarow in .net

    I have a dataset with order and orderdetail tables and i want to make a copy of an order table row and for that I will be trying to clone a DataRow (see below) but I have a syntax error referring to the implicit conversion from object to datarow. I don't see a clone or copy method on the DataRow.

  2. #2
    Join Date
    Mar 2008
    Posts
    192

    Re: Cloning datarow in .net

    It depends if it is for the same datatable or that you want to put it in an other datatable. Just add a new row to the order table, then add new rows to the orderdetails, then fill columns with the appropriate values from the original data rows.

    Code:
    Dim drNew As DataRow
    
    'Add Row 0 with Manufactred Product details
    
    dt = dtOrderDetails.Clone
    
    drNew = dtOrderDetails.Rows(0)
    
    dt.ImportRow(drNew)
    Be aware that with strongly typed datasets the merge is an important method, while it is in my idea with non typed ones mostly ignored.

  3. #3
    Join Date
    Feb 2008
    Posts
    129

    Re: Cloning datarow in .net

    To deepcopy a datarow you need the schema which is in the datatable. Therefore I think that the most simple methods are to use or the importrow or the loaddatarow from that. Just add a new row to the order table, then add new rows to the orderdetails, then fill columns with the appropriate values from the original data rows.

  4. #4
    Join Date
    Oct 2008
    Posts
    180

    Re: Cloning datarow in .net

    DataTable Clone Method

    Clones the structure of a DataTable, including all DataTable schemas and constraints. See comment *1 in the example code. It is not evident how we can clone a row that has, for example, some unique columns.

    C1.Data.C1DataRow newRow = c1DataSet1.TableViews["Orders"].AddNew();
    newRow["Field1"] = oldRow["Field1"];

Similar Threads

  1. what is sim cloning??
    By Bronoe in forum Portable Devices
    Replies: 6
    Last Post: 06-01-2012, 07:08 AM
  2. Cloning in Java
    By blueprats in forum Guides & Tutorials
    Replies: 4
    Last Post: 25-02-2010, 06:50 AM
  3. Disc Cloning in MAC
    By Edwards in forum Windows Software
    Replies: 5
    Last Post: 15-02-2010, 10:00 AM
  4. Need help in cloning MAC address
    By supernoob in forum Technology & Internet
    Replies: 5
    Last Post: 19-12-2009, 07:00 PM
  5. How to copy a datarow from one table to another?
    By Vaibhav S in forum Software Development
    Replies: 4
    Last Post: 21-07-2009, 07:32 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,865,851.40265 seconds with 16 queries