数据表行复制问题 [英] Datatable Row Copiying Issue

查看:76
本文介绍了数据表行复制问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据表,现在我要将具有相同值的第一行复制到第二行...
请帮助.

I have a Datatable , Now I want to copy the 1st Row with same values to 2nd Row...
Pls help.

推荐答案

每个DataRow都有一个ItemArray属性,该属性实际上保存数据,因此您只需要使用以下内容:-
Each DataRow has an ItemArray property which actually holds the data, so you just need to use something like this:-
table.Rows.Add(table.Rows[0].ItemArray);


整个想法没有任何意义.您可能不完全了解关系模型.没有第一行或第二行.从SQL用户(或通常是关系数据库客户端)的角度来看,没有定义行顺序.

排序是数据库存储的内部问题,它是从用户中抽象出来的.甚至在内部,也没有明确定义.相反,您可以谈论索引.请参阅:
http://en.wikipedia.org/wiki/Database_index [ http://en.wikipedia.org/wiki/Primary_key [
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


这篇关于数据表行复制问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆