Clone from one Dataset to Another

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 2 datasets that are connected from 2 different dataadapters and sources, I need to copy a DataTable from one dataset to another. Is there a function to clone a datase

Thanks Glenn
 
There are different ways of doing this, noen of them "simple". Here's one
way, involving a separate DataTable object.

Dim northwindConnection As New SqlConnection("...")

Dim firstDataSet As New DataSet

Dim secondDataSet As New DataSet

Dim productsDataTable As DataTable

Dim firstAdapter As New SqlDataAdapter("SELECT * FROM Customers",
northwindConnection)

Dim secondAdapter As New SqlDataAdapter("SELECT * FROM Products",
northwindConnection)

firstAdapter.Fill(firstDataSet)

secondAdapter.Fill(secondDataSet)

productsDataTable = secondDataSet.Tables(0).Copy

productsDataTable.TableName = "Products"

firstDataSet.Tables.Add(productsDataTable)


--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
Glenn Wilson said:
I have 2 datasets that are connected from 2 different dataadapters and
sources, I need to copy a DataTable from one dataset to another. Is there a
function to clone a dataset
 
Hi Glen,

Yes there is the database.copy which makes a full copy and the dataset.clone
which makes a clone of the schema with an empty dataset

I hope this helps?

Cor
 
Will this work if I have the two dataadapters connected to two different
database servers, and then once copied to the secondary adapter update the
data to the second server..

ie
Conn1 connects to adapter1 and has dataset1
conn2 connects to adapter2 and has dataset2

I then follow your copy method to the dataset2 and fire the update to update
the database conn2,

will this successfully transfer the data and changes
 
Back
Top