473,388 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Copy / Clone DataTable?

nev
251 100+
I have a datatable dtt1 with data in it. It is bind to bs1

Then I do...

dtt2 = dtt1.copy

Thinking that I will be able to manipulate dtt2 without affecting dtt1...

I assign a bindingsource bs2.datasource = dtt2

But when I manipulate bs2, for example sorted it, bs1 also gets sorted. What's the problem here?

Anybody knows how I can manipulate bs2 without affecting bs1???
Oct 15 '07 #1
4 1761
nev
251 100+
I tried this but the result is still the same

bs1 is binded to dtt1

dtt2 = dtt1.clone

For i As Integer = 0 To dtt1.Rows.Count - 1
dtt2.ImportRow(dtt1.Rows(i))
Next

bs2.datasource = dtt2

When I sort bs2, bs1 still gets sorted also.
Oct 15 '07 #2
nev
251 100+
I got it myself... here, I'll share it.

dtt2.clear()

dtt2.merge(dtt1)

bs2.datasource = dtt2

Any manipulation done to bs2 is reflected only to bs2.

Thanks for all those who helped :-)
Oct 15 '07 #3
chandru8
145 100+
hi
can you please explain the code you are doing...
Oct 15 '07 #4
nev
251 100+
The code I'm trying to do is to find a faster way to copy data from one datatable to another without the bind compared to using a loop.
Oct 15 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dianna K. | last post by:
I have a dataview which I am assigning to a Datatable (I am doing this because currently Crystal Reports will not accept a dataview as a Reportsource -- The recommended work-around is to assign...
42
by: Edward Diener | last post by:
Coming from the C++ world I can not understand the reason why copy constructors are not used in the .NET framework. A copy constructor creates an object from a copy of another object of the same...
3
by: Matthew Wieder | last post by:
I have a datatable as a source and I need to produce a datatable which is all the rows in the original datatable except the first row, copied n times. So, if I had a datatable of: A B C...
0
by: Kelvin | last post by:
Hi All, Due to can't insert new row between row and row while current DataTable looping. In order to solve the problem, I need to clone it as new DataTable, while the DataTable Looping, it also...
2
by: JC Voon | last post by:
Hi: What is the best way to copy the schema of one DataTable to another ?, The DataTable.Clone will create a new DataTable Currently i do it manually destTable.Clear()...
5
by: Katit | last post by:
I get dataset from database. I need to take specific datatable out of it and add it to second dataset to pass back from webservice. ds.Tables.Add(dsPart.Tables); I get exception "Datatable...
4
by: Férnas | last post by:
Hey guys, In my app, I have a DataTable named "dta"... If i create a new variable of DataTable type named "dta2", and assign the dta as value, it creates a reference to dta, then, when I make...
3
by: Manuel | last post by:
Hi to all, I'm trying to copy a Datacolumn from a table to another, but with this code: destTable.Columns.Add(srcTable.Column); I got this error: Column 'colname' already belongs to another...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.