//////列表名 /// /// ///public static string GetColumnNames(System.Data.DataTable table) { if (table != null) { List lstColumn = new List (); foreach (System.Data.DataColumn col in table.Columns) { lstColumn.Add(col.ColumnName); } return String.Join(",", lstColumn.ToArray()); } return string.Empty; //foreach (DataRow row in table.Rows) //{ // foreach (DataColumn column in table.Columns) // { // ColumnName = column.ColumnName; // ColumnData = row[column].ToString(); // } //} } /// /// 数据类型 /// /// ///public static string GetColumnNamesType(System.Data.DataTable table) { if (table != null) { List lstColumn = new List (); foreach (System.Data.DataColumn col in table.Columns) { lstColumn.Add(table.Columns[col.ColumnName].DataType.ToString()); } return String.Join(",", lstColumn.ToArray()); } return string.Empty; } /// /// 列名和数据类型 /// /// ///public static DataTable GetColumnDataNamesType(System.Data.DataTable table) { DataTable dt = new DataTable(); dt.Columns.Add("name", typeof(string)); dt.Columns.Add("datatype", typeof(string)); if (table != null) { foreach (System.Data.DataColumn col in table.Columns) { dt.Rows.Add(col.ColumnName, table.Columns[col.ColumnName].DataType.ToString()); } } return dt; }