private void getCompare()
{
//两个结构一样的DT合并
DataTable dt1 = new DataTable();
string strsql = "";
string strday = DateTime.Now.Date.ToString("yyyyMMdd").Trim();//取系统时间-年月日
strsql = "select cast(0 as bit) '选项',ltrim(rtrim(MA001)) '客户编号',ltrim(rtrim(MA003)) '客户名称' from COPMA ";
strsql += "where MA068>='" + strday + "'";
dt1 = dcns.ExeDataTable(strsql, 3);
DataTable dt2 = new DataTable();
string strsql2 = "";
strsql2 = "select cast(0 as bit) '选项',ltrim(rtrim(C_id)) '客户编号',ltrim(rtrim(C_name)) '客户名称' from TabCust ";
strsql2 += "where W_id=0 and W_isok=0";
dt2 = dcns.ExeDataTable(strsql2, 1);
DataTable newdt = dt1.Clone();
object[] obj = new object[newdt.Columns.Count];
for (int i = 0; i < dt1.Rows.Count; i++)
{
dt1.Rows[i].ItemArray.CopyTo(obj,0);
newdt.Rows.Add(obj);
}
for (int i = 0; i < dt2.Rows.Count; i++)
{
//object[] obj2 = new object[dt3.Columns.Count];
dt2.Rows[i].ItemArray.CopyTo(obj,0);
newdt.Rows.Add(obj);
newdt.Rows.RemoveAt(i);
newdt.AcceptChanges();
}
dataGridView1.DataSource = newdt;
}
我已经把两个表合并到一个DataTable ,如何不显示重复的行