合并:

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合并及排除重复方法的更多相关文章

  1. ASP.Net【如何合并DataTable,并且去重复方法】

    虽然DataTable.Merge可以很好的实现,但以下代码写出来更好理解 DataTable DataTable1 = new DataTable(); DataTable DataTable2 = ...

  2. 取两个DataTable的交集,删除重复数据

    /// <summary> /// 取两个DataTable的交集,删除重复数据 /// </summary> /// <param name="sourceD ...

  3. 2016年11月30日 星期三 --出埃及记 Exodus 20:21

    2016年11月30日 星期三 --出埃及记 Exodus 20:21 The people remained at a distance, while Moses approached the th ...

  4. 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 ...

  5. 2016年11月28日 星期一 --出埃及记 Exodus 20:19

    2016年11月28日 星期一 --出埃及记 Exodus 20:19 and said to Moses, "Speak to us yourself and we will listen ...

  6. 2016年11月27日 星期日 --出埃及记 Exodus 20:18

    2016年11月27日 星期日 --出埃及记 Exodus 20:18 When the people saw the thunder and lightning and heard the trum ...

  7. 2016年11月26日 星期六 --出埃及记 Exodus 20:17

    2016年11月26日 星期六 --出埃及记 Exodus 20:17 "You shall not covet your neighbor's house. You shall not c ...

  8. 2016年11月25日 星期五 --出埃及记 Exodus 20:16

    2016年11月25日 星期五 --出埃及记 Exodus 20:16 "You shall not give false testimony against your neighbor.不 ...

  9. 2016年11月24日 星期四 --出埃及记 Exodus 20:15

    2016年11月24日 星期四 --出埃及记 Exodus 20:15 "You shall not steal.不可偷盗.

随机推荐

  1. DanceLink

    DanceLink是一个可以解决精确覆盖和重复覆盖的搜索算法 重复覆盖就是在精确覆盖的remove等处做改变 都是十字循环链表 精确覆盖 给出一个01矩阵 要求选择几行 使每一列都有且仅有一个1 在求 ...

  2. Java -- JDBC 获取数据库自动 生成的主键值

    public class Demo4 { /* create table test1 ( id int primary key auto_increment, name varchar(20) ); ...

  3. poj 1011 :Sticks (dfs+剪枝)

    题意:给出n根小棒的长度stick[i],已知这n根小棒原本由若干根长度相同的长木棒(原棒)分解而来.求出原棒的最小可能长度. 思路:dfs+剪枝.蛮经典的题目,重点在于dfs剪枝的设计.先说先具体的 ...

  4. KNN cosine 余弦相似度计算

    # coding: utf-8 import collections import numpy as np import os from sklearn.neighbors import Neares ...

  5. Multiprovide 实践理解

    “多重提供器”是一种“信息提供者”,它综合了多个“信息提供者”的数据以用于报告.“多重提供者”本身不包含任何数据.“多重提供者”的数据由所基于的“信息提供者”专门提供,这些“信息提供者”组合在一起进行 ...

  6. spring学习-4

    bean的作用域 使用bean的scope属性来配置bean的作用域 scope="singleton":默认是单例模式即容器初始化创建bean实例,在整个容器的生命周期内只创建这 ...

  7. nginx配置允许指定域名下所有二级域名跨域请求

    核心原理是根据请求域名匹配是否是某域名的二级域名判断是否添加允许跨越头. #畅游www server { listen 8015; server_name test-tl.changyou.com; ...

  8. 2017-2018-1 20179215《Linux内核原理与分析》第十二周作业

    Sql注入基础原理介绍 分组:和20179205王雅哲共同完成实验 一.实验说明 1.1 sql注入  SQL注入攻击通过构建特殊的输入作为参数传入Web应用程序,而这些输入大都是SQL语法里的一些组 ...

  9. Java 参数的和

    public class CommandParamter { public static void main(String[] args) { // TODO Auto-generated metho ...

  10. webpack 配置简单说几句 ?

    前言 这几天在准备一个单页面应用, 准备试试webpack神器,在准备webpack下的知识点,顺便记录下一些使用的心得. webpack 的配置说明 在近来的前端开发中,业务逻辑复杂化,层次多样化, ...