#region Get new DataTable///<summary>///for fixed columns do not duplicate new DataTable///</summary>///<para M name= "DT" > Datatable</param>///containing duplicate data <param name= "colname" > Need to verify duplicate column names </param>///<retu Rns> new Datatable,colname columns are not duplicated, table-style remains unchanged </returns> private DataTable getdistincttable (DataTable DT, string colname) {if (dt. Rows.Count = 0 | | Dt.
Rows.Count = = 1) {WriteFile ("getdistincttable The number of rows passed into DT is less than or equal to 1" + "\ r \ n", LogName, out outmessage);
return DT; } DataView dv = dt.
DefaultView; Duplicate column name DataTable Dtcardno = DV in DV filter DV.
ToTable (True, colname);
DataTable Pointdt = new DataTable ();
ToTable () Creates and returns a new DataTable based on the rows in the existing DataView. The output table contains the same column POINTDT = DV as the input table.
ToTable ();
Pointdt.clear (); for (int i = 0; i < DtCardNo.Rows.Count i++) {try {//dr takes the DAT that is returned by select Arow[] in the firstA piece of data//if DTCARDNO.ROWS[I][0]. There is no value in ToString () that will count out the error if (!string) that the group exceeded the index bounds. IsNullOrEmpty (Dtcardno.rows[i][0]. ToString ())) {DataRow dr = dt. Select (colname + "= '" + dtcardno.rows[i][0].
ToString () + "'") [0]; Datarow.itemarray uses an array to get or set all the values for this row Pointdt.Rows.Add (Dr.
ItemArray);
} catch (Exception ee) {//can write error to log file}}
return POINTDT; } #endregion
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/aspx/