2016.8.11 DataTable合并及排除重复方法
合并:
DataTable pros=xxx;
DataTable pstar=yyy;
//将两张DataTable合成一张
foreach (DataRow dr in pstar.Rows)
{
pros.ImportRow(dr);
}
DataTable设置主键,并判断重复
DataTable allpros =xxx;
单列设为主键:
//设置第某列为主键
allpros.PrimaryKey = new DataColumn[] { pros.Columns[0]};
foreach (DataRow dr in pros.Rows)
{
//排除相同id,相同类型的程序
if (!allpros.Rows.Contains(dr[0]}))
allpros.ImportRow(dr);
}
多列设为主键
allpros.PrimaryKey = new DataColumn[] { pros.Columns[0], pros.Columns[1] };
if (!allpros.Rows.Contains(new object[2]{dr[0],dr[1]}))
allpros.ImportRow(dr);
2016.8.11 DataTable合并及排除重复方法的更多相关文章
- ASP.Net【如何合并DataTable,并且去重复方法】
虽然DataTable.Merge可以很好的实现,但以下代码写出来更好理解 DataTable DataTable1 = new DataTable(); DataTable DataTable2 = ...
- 取两个DataTable的交集,删除重复数据
/// <summary> /// 取两个DataTable的交集,删除重复数据 /// </summary> /// <param name="sourceD ...
- 2016年11月30日 星期三 --出埃及记 Exodus 20:21
2016年11月30日 星期三 --出埃及记 Exodus 20:21 The people remained at a distance, while Moses approached the th ...
- 2016年11月29日 星期二 --出埃及记 Exodus 20:20
2016年11月29日 星期二 --出埃及记 Exodus 20:20 Moses said to the people, "Do not be afraid. God has come t ...
- 2016年11月28日 星期一 --出埃及记 Exodus 20:19
2016年11月28日 星期一 --出埃及记 Exodus 20:19 and said to Moses, "Speak to us yourself and we will listen ...
- 2016年11月27日 星期日 --出埃及记 Exodus 20:18
2016年11月27日 星期日 --出埃及记 Exodus 20:18 When the people saw the thunder and lightning and heard the trum ...
- 2016年11月26日 星期六 --出埃及记 Exodus 20:17
2016年11月26日 星期六 --出埃及记 Exodus 20:17 "You shall not covet your neighbor's house. You shall not c ...
- 2016年11月25日 星期五 --出埃及记 Exodus 20:16
2016年11月25日 星期五 --出埃及记 Exodus 20:16 "You shall not give false testimony against your neighbor.不 ...
- 2016年11月24日 星期四 --出埃及记 Exodus 20:15
2016年11月24日 星期四 --出埃及记 Exodus 20:15 "You shall not steal.不可偷盗.
随机推荐
- spark学习6(Centos下Scala2.11.4安装)
Centos下Scala安装 上传Scala到/usr/scala目录下 [root@spark1 scala]# chmod u+x scala-2.11.4.tgz #修改权限 [root@spa ...
- ubuntu安装Qt5
1.ubuntu 10.04 desktop amd64 问题: 1.1. 没有GLIBCXX_3.4.15版本,或是更高的版本 http://blog.chinaunix.net/uid-91530 ...
- postgresql查看数据库占用的物理存储空间大小
1.手动查看: 查看数据库postgres的oid postgres=# SELECT oid from pg_database where datname='postgres'; oid------ ...
- TY_GASPX SQL
SELECT company_name,cp_province,cp_city,cp_area,worktype_name,SUM(allpass) as allCount FROM [dbo].[E ...
- thinkphp框架的优缺点
ThinkPHP的优缺点如下: 1.高级模型:可以轻松支持序列化字段.文本字段.只读字段.延迟写入.乐观锁.数据分表等高级特性. 2.视图模型:轻松动态地创建数据库视图,多表查询相对简单. 3.关联模 ...
- uva 10453 dp/LCS变形
https://vjudge.net/problem/UVA-10453 给出一个字符串,问最少添加几个字符使其变为回文串,并输出任意一种答案.就是一个类似于LCS的题目,而且简化了一下,只会出现三种 ...
- Redis集群部署3.0
我用的Mac的终端 ------------------------- 1.Redis简介 centos(5.4) Redis是一个key-value存储系统.和Memcached类似,但是解决了断 ...
- MySQL 索引 视图 触发器 存储过程 函数
1.索引 索引相当于图书的目录,可以帮助用户快速的找到需要的内容. 数据库利用各种各样的快速定位技术,能够大大提高查询效率.特别是当数据量非常大,查询涉及多个表时,使用索引往往能使查询速度加快成千上万 ...
- 分布式_理论_02_Base 理论
一.前言 五.参考资料 1.分布式理论(二)——Base 理论 2.分布式理论(二) - BASE理论
- 信息标记 以及信息提取--xml-json-yaml
1 信息标记的三种方式: XML: JSON: YAML: 1 缩进 表示所属关系: 2 - 表示并列关系: 3 | 表示整块数据: HTML----XML的一种形式: 2 信息提取的方法: ...