Solved

creating a backup copy of a datatable

Posted on 2013-01-30
2
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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