?
Solved

creating a backup copy of a datatable

Posted on 2013-01-30
2
Medium Priority
?
174 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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