Solved

creating a backup copy of a datatable

Posted on 2013-01-30
2
165 Views
Last Modified: 2013-01-30
hi -- i'm using vs2010 and .net 4.
i'm trying to create a backup copy of a data table that can be used in the application to compare changes from the working copy to the backup copy. it appears that most of the methods available (clone and copy) create a new pointer to the original datatable - so that when modifications are made, the "backup" reflects the modifications. i've tried this a couple different ways, but they all seem to do the same thing (ie create a pointer to the same data). i've tried using item array to copy the data, but i get the same results. how do i create the backup version so that it is indeed a copy and not a pointer? my code is below:

// Create a backup copy of the DtChannelSet
                backupChannelSet = uc.DtChannelSet.Clone();
               
                foreach (DataRow drs in uc.DtChannelSet.Rows)
                {
                    backupChannelSet.ImportRow(drs);            
                }
0
Comment
Question by:jdcoburn
2 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 38837041
backupChannelSet = uc.DtChannelSet.Clone();
               
                foreach (DataRow drs in uc.DtChannelSet.Rows)
                {
                    backupChannelSet.Rows.Add(drs.ItemArray);            
                }
0
 

Author Closing Comment

by:jdcoburn
ID: 38838265
thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now