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

DataTable to DataTable

Hi All,
I'm having a DataTable with say 3 columns. I've to copy this DataTable
to another DataTable which has 4 columns. The extra column is the
Row_ID with AutoIncrement property set true.

Is this way is possible?

Anyways, what I actually need is to add a new column Row_ID with
AutoIncrement values.

Source Table
EName EDesignation
Abc Engineer
Bcd Sr.Engineer

Destination Table should be like this
Row_ID EName EDesignation
1 Abc Engineer
2 Bcd Sr.Engineer

Thats it,

Thanks in Advance
ArunDhaJ
Aug 4 '08 #1
6 1441
On Aug 4, 9:42*am, ArunDhaJ <arund...@gmail.comwrote:
Hi All,
I'm having a DataTable with say 3 columns. I've to copy this DataTable
to another DataTable which has 4 columns. The extra column is the
Row_ID with AutoIncrement property set true.

Is this way is possible?

Of course, just do a loop in the first table rows and add a new row to
the second one.
Aug 4 '08 #2
Is there any way other than looping? As the DataTable would contain
more than 20K records, in that case this would easily infects the
performance.

Thanks
ArunDhaJ
Aug 4 '08 #3
On Aug 4, 6:28*pm, ArunDhaJ <arund...@gmail.comwrote:
Is there any way other than looping? As the DataTable would contain
more than 20K records, in that case this would easily infects the
performance.
Since DataTable is an in-memory structure, and is, in fact, just a
glorified List<DataRowwith optional indexing and constraint
checking, there isn't a more efficient way to do what you want (just
as there wouldn't be with plain List<T>).
Aug 4 '08 #4
On Aug 4, 10:28 am, ArunDhaJ <arund...@gmail.comwrote:
Is there any way other than looping? As the DataTable would contain
more than 20K records, in that case this would easily infects the
performance.

Thanks
ArunDhaJ

Well, anything with 20K rows in memory will have an impact !!!

Besides, think about it, even if YOU do not do the loop, somebody else
would have to do it :). There is no way to avoid the loop

I think you better use a DB, cause 40k rows (20k*2 tables) are a lot
to be hold in memory
Aug 4 '08 #5
Ya. That was the final option which I had. And now proceeding in that
way. :-)
Thanks for your guidance..

Regards
ArunDhaJ
Aug 5 '08 #6
On Aug 5, 1:03*am, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
I think you better use a DB, cause 40k rows (20k*2 tables) are a lot
to be hold in memory
Not really - at 1k per row (which is probably an overestimate), it's
still only 40Mb, which isn't all that much. In fact, if you use SQL
Server with a database of that size, it will likely also load the data
entirely into memory to speed up queries.

Of course, a proper database is still preferrable as soon as you start
to do queries which are more complicated than "WHERE Name = 'John'".
Aug 5 '08 #7

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

Similar topics

5
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the...
5
by: Stefan Turalski \(stic\) | last post by:
Hi, I'm wondering if there is a way to send a method parametrs by ref when DataTabel is a type of this value ? I done some sort of select over DataTable columns, just by removing them froma...
1
by: TaeHo Yoo | last post by:
Hi all, After sorting and grouping data using a dataview, then how to transfer the changed datatable in the dataview to a datatable in C#? Cheers
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
7
by: Raymond Lewallen | last post by:
Which would be the proper way or the reason for using any of the following or combinations of the following? These are the 3 ways I've figured I can do what I want to do, I just don't know which...
3
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
6
by: Pete Wittig | last post by:
Hi, I have a DataTable and I want to get a subset of the rows within it. I use the Select method to get my subset and the results are in a DataRow. I want to put those Rows back into a...
0
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: ...
5
by: Frank Hauptlorenz | last post by:
Hello, I recognized some days ago, that returning a DataTable blocks my WCF-Service. Is this a known bug? If I add this table to a new DataSet() and return this, it works. Thank you, Frank
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.