Solved

creating a backup copy of a datatable

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

15 Experts available now in Live!

Get 1:1 Help Now