对C# DataTable的列实现distinct即去重的功能

实际上是在原有的datatable上面,新组成一个datatable

对C# DataTable的列实现distinct即去重的功能_第1张图片对C# DataTable的列实现distinct即去重的功能_第2张图片

 if (this.textBoxNDYF.Text.Trim() == "" && this.comboBoxGC.Text.Trim() == ""
                    && this.textBoxWLBM.Text.Trim() == "" && !radioButton1.Checked && !radioButton2.Checked)
                {
                    DataTable dtDJH = new DataTable();
                    DataView dv = dt.DefaultView;
                    dtDJH = dv.ToTable(true, new string[] { "DJH" });

                    string err = "";
                    if (dtDJH.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dtDJH.Rows)
                        {
                            err = BLL.WLCG.DeleteYWLBMCGJHHZData(dr["DJH"].ToString());
                            err = BLL.WLCG.DeleteYWLBMCGJH1Data(dr["DJH"].ToString());
                        }
                    }
                    bool flag = Util.DBHelper.AddTable(dt, "YWLBMCGJH1");
                    flag = Util.DBHelper.AddTable(dt, "YWLBMCGJHHZ");
                    if (!flag)
                    {
                        MessageBox.Show("数据插入表失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

 

你可能感兴趣的:(C#,工作)