[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Copying records

Posted on 2006-05-04
Medium Priority
Last Modified: 2010-04-23
I have a record that I need to duplicate except for a couple fields.  The record has about 20 fields, I need to copy it in full except for 2 fields.  I need to modify those fields to values the user inputs.  Anyone have a suggestion on how to do this?

Question by:Gawron3
LVL 64

Expert Comment

by:Fernando Soto
ID: 16611669
Need more info.
The record, is it from a file?
Is it going to be written back out to a file?
How are the  fields separated?
Are the fields fixed width?
VS .Net 2003 or .Net 2005?

Author Comment

ID: 16616430
THe table is an access table with about 20 fields in it.  THe record I want to copy will be a record in that same table, but I will need to change a couple fields on the new record.  It is with .net 2003.
LVL 34

Accepted Solution

Sancler earned 750 total points
ID: 16617238
Here's the basic technique

        Dim newdr As DataRow = MyTable.NewRow
        Dim olddr As DataRow = MyTable.Rows(<index of row to copy>)
        newdr.ItemArray = olddr.ItemArray
        'you can make changes to values in new row programmatically here
        'or the user can do so after this if the new record is then displayed in bound controls

You can modify it - e.g. only to copy over some of the items - by replacing this line

        newdr.ItemArray = olddr.ItemArray

with something on the lines of

        newdr(<index of item to copy>) = olddr(<index of item to copy>)

repeated for each item that you want copied


Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

873 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