将需要对比的列查询输出在DataTable中,然后使用方法进行对比
/// <summary> /// 判断DataTale中判断某个字段中包含某个数据 /// </summary> /// <param name="dt"></param> /// <param name="columnName"></param> /// <param name="fieldData"></param> /// <returns></returns> public static Boolean IsColumnIncludeData(DataTable dt, String columnName, string fieldData) { if (dt == null) { return false; } else { DataRow[] dataRows = dt.Select(columnName + "='" + fieldData + "'"); if (dataRows.Length.Equals(1)) { return true; } else { return false; } } }