zoukankan      html  css  js  c++  java
  • 删除DataTable中重复的记录

     /// <summary>
            /// 删除DataTable中重复的记录  

          /// </summary>
            /// <param name="ds"></param>
            /// <returns></returns>
            public DataSet DeleteSameData(DataSet ds)
            {
                DataSet resultds = ds.Clone();
                DataSet Tempds=ds;        

                int count = 0;        

                if (ds != null && ds.Tables.Count > 0)
                {
                    count = ds.Tables[0].Rows.Count;

                    for (int i = 0; i < count; i++)
                    {
                        DataRow dri = Tempds.Tables[0].Rows[i];

                        if (dri.RowState == DataRowState.Deleted) continue;

                        resultds .Tables[0].ImportRow(dri);

                        for (int j = i + 1; j < count; j++)
                        {
                            DataRow drj = Tempds.Tables[0].Rows[j];
                            if (drj.RowState == DataRowState.Deleted) continue;
                             if (anwercount <= 1) continue;

                            //判断相同
                            bool flage = false;
                            flage = JudgeSame(dri, drj);
                            if (flage)
                            {
                                //除去相同

                                Tempds.Tables[0].Rows[j].Delete();
                            }
                           

                        }
                    }

                }   


                return resultds ;
            }
          

  • 相关阅读:
    HttpClient访问的策略Policy
    Fiddler 工具使用技巧
    设置Chrome浏览器User-Agent
    anaconda Script file Scriptspip-script.py is not present
    anaconda3+ paddleOCR安装使用
    anaconda 创建虚环境 必须指定python版本
    pyqt 启动GUI前启动子进程,退出GUI后退出子进程
    pyqt 扩展QsciScintilla disable mouse select
    pyqt designer下添加QsciScintilla 控件
    rdkit 读mol时保留H原子
  • 原文地址:https://www.cnblogs.com/discoverx/p/2185043.html
Copyright © 2011-2022 走看看