?
Solved

Copy DataRows between in-memory Datasets

Posted on 2011-09-22
2
Medium Priority
?
276 Views
Last Modified: 2012-05-12
HOW TO - Copy DataRows between in-memory Datasets

        Dim dsIN As New Data.DataSet
... more code ...
        objDataAdapter.Fill(dsIN)

ok ... here I have a Dataset with ONE table
Now I want to DUPLICATE THE TABLE, ITS SCHEMA AND CONTENTS to a NEW dataset
I create the new dataset on-the-fly in-memory


        Dim dsCOPY As DataSet = New DataSet()
        dsCopy.Tables.Add(New DataTable("MyCopy"))
        For Each dc As DataColumn In dsIN.Tables(0).Columns
            dsCopy.Tables("MyCopy").Columns.Add(New DataColumn(dc.ColumnName, dc.DataType))
        Next

OK dsCOPY now duplicates the structure of dsIN
How do I copy all the records from dsIN into dsCopy
I thought this would work ... IT DOES NOT


        For Each drIN As DataRow In dsIN.Tables(0).Rows
            dsCopy.Tables(0).Rows.Add(drIN)
        Next

I get an error message on the dsCopy line ... "This row already belongs to another table."

Fred

0
Comment
Question by:volking
[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
2 Comments
 
LVL 5

Accepted Solution

by:
volking earned 0 total points
ID: 36582462
Found solution myself  

http://support.microsoft.com/kb/305346

0
 
LVL 5

Author Closing Comment

by:volking
ID: 36582463
Found the solution myself
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
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