Click here to Skip to main content
15,917,059 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have a Datatable , Now I want to copy the 1st Row with same values to 2nd Row...
Pls help.
Posted
Comments
Sergey Alexandrovich Kryukov 19-Mar-12 2:25am    
First, this is not a question. Secondly, this would-be a question makes no sense; I explain it in my answer; please see.
--SA

Each DataRow has an ItemArray property which actually holds the data, so you just need to use something like this:-
C#
table.Rows.Add(table.Rows[0].ItemArray);
 
Share this answer
 
The whole idea makes no sense. You probably do not completely understand relational model. There is no such thing as first row or second row. Row ordering is not defined from the standpoint of a SQL user (or a relationship database client in general).

Ordering is the internal issue of the database storage, which is abstracted from the user. And even internally, it is not unambiguously defined. Rather, you can speak about indexing. Please see:
http://en.wikipedia.org/wiki/Database_index[^].

An exact copy of a row to another row of the same table is also not a consistent operation which would make sense, because a primary key of a table is maintained unique. An attempt to add a record withe the same primary key would be failed by a RDBMS. Please see:
http://en.wikipedia.org/wiki/Primary_key[^].

Again, it makes no sense.

—SA
 
Share this answer
 
v2
Comments
ProEnggSoft 19-Mar-12 2:28am    
Good explanation. 5!
Sergey Alexandrovich Kryukov 19-Mar-12 2:28am    
Thank you.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900