473,387 Members | 1,925 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,387 software developers and data experts.

Split a DataTable into two DataTables

Hi, I have a DataTable which I want split into two other datatables
with the top 1/2 of the original datatable in one datatable and the
other 1/2 in another datatable.

Is there any easier way to do this other than iterating through the
original datatable row by row and copying the row to a new datatable??

Thanks
Markus

May 23 '07 #1
2 6399
Markus,

If you have a criteria that you could use to search through the
DataTable, you could use the Select method on the DataTable to select the
appropriate rows out, and then iterate through those, copying them over.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<Ma*******@gmail.comwrote in message
news:11**********************@z28g2000prd.googlegr oups.com...
Hi, I have a DataTable which I want split into two other datatables
with the top 1/2 of the original datatable in one datatable and the
other 1/2 in another datatable.

Is there any easier way to do this other than iterating through the
original datatable row by row and copying the row to a new datatable??

Thanks
Markus
May 23 '07 #2
On May 23, 10:48 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Markus,

If you have a criteria that you could use to search through the
DataTable, you could use the Select method on the DataTable to select the
appropriate rows out, and then iterate through those, copying them over.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

<Markus...@gmail.comwrote in message

news:11**********************@z28g2000prd.googlegr oups.com...
Hi, I have a DataTable which I want split into two other datatables
with the top 1/2 of the original datatable in one datatable and the
other 1/2 in another datatable.
Is there any easier way to do this other than iterating through the
original datatable row by row and copying the row to a new datatable??
Thanks
Markus- Hide quoted text -

- Show quoted text -
Hi, thanks for your help :)
Regards
Markus

May 28 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
1
by: cax | last post by:
Hi there. I am fixing an c# app. compiled to dotnet 1.1. Yet I want to port it for dotnet 2.0. But in some part of code there is a casting from an array of objects to a datatable that generates an...
10
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I...
1
by: Tom W | last post by:
code snipped from MS sample "N-Tier Data Form and Data Layer" example (101 vb.net samples). Public Class frmMain Private dsSupplierProducts as DataSet Private dtSupplier as DataTable Private...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
11
by: inpuarg | last post by:
I have 2 datatables. They are identical. I want to compare them by cell's content. They are all same. But dt1 == dt2 or dt1.GetHashCode() == dt2.GetHashCode() doesn 't work. There are big...
9
by: =?Utf-8?B?RGljaw==?= | last post by:
I have a function that creates a DataSet, populates its many DataTables and then returns the DataSet. I want to bind separate controls to each of the DataSet's DataTables, e.g. a separate...
1
by: csharpula csharp | last post by:
Hello, Could you please tell me the difference between DataSet and DataTable? Thank u! *** Sent via Developersdex http://www.developersdex.com ***
5
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.