I have lost my mind!

Perhaps, it’s true 🙂 (and hopefully just momentary…)

I have LOST MY MIND!

this works just fine:

Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection(“server=myserver;Trusted_Connection=True;Database=pubs”)

Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand(“select * from authors”, conn)

Dim da As New SqlDataAdapter(cmd)

Dim ds As New DataSet

da.Fill(ds)

Dim ds2 As New DataSet

Dim t As DataTable = ds.Tables(0).Copy

ds2.Tables.Add(t)

what happened to the “DataTable belongs to another dataset“ exception? Was it only in 1.0 and I just never tried it again with 1.1? I know I struggled with this forever a long time ago.

oh do I need a vacation.

Rather than just searching for workarounds or whining about this problem in my blog, I have submitted a suggestion in the Product Feedback Center. If you think this will help you, go vote on it. If you think this is a stupid idea, go vote on it.

Problem Statement:
Opened by Julie Lerman on 2005-01-16 at 11:53:05
   
In .net 1.1 we had to find workarounds to get a copy of a DataTable that is part of one DataSet into another DataSet. Many devs wasted a lot of time with Copy and Clone thinking there *must* be a way.

In .NET 2.0 it looks like the best way to do this now is with CreateDataReader, Load into new DataTable then add DataTable to DataSet.

 

Proposed Solution: Create DataTable method that will create a new DataTable that does NOT have the connection to the parent DataSet? Either a method or a parameter of Copy?

Thanks.



http://www.AcehAid.org

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.