//DataTable转String方法 public static String DataTable2String(DataTable dt) { string strXML = "<DataTable>\r\n"; try { foreach (DataRow dr in dt.Rows) { strXML += "<Row>\r\n"; foreach (DataColumn dc in dt.Columns) { strXML += string.Format("<Column name=‘{0}‘ value=‘{1}‘>\r\n", dc.ColumnName, dr[dc.ColumnName]); } strXML += "</Row>\r\n"; } } catch (Exception e) { strXML += string.Format("DataTable2String异常:" + e.Message); } strXML += "</DataTable>"; return strXML; }
时间: 2024-10-25 16:10:32