Solved

creating a backup copy of a datatable

Posted on 2013-01-30
2
167 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading the Web.Config using IIS 7.5? 4 36
C# bracket error 3 31
VB.NET 2008 - SQL Timeout 9 24
How to seperate number and letters from a string 3 7
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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

770 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