dataset操作
1 自己添加
代码
ds.Tables.Add("Table1");
. ds.Tables[0].Columns.Add("ErrMessage", typeof(string));
//DataTable dt = new DataTable();
//dt.Columns.Add("Remark", typeof(string));
//dt.TableName = "Table1";
//dt.Columns.Add("FixName", typeof(string));
DataRow dr = ds.Tables[0].NewRow();
dr[0] = err.Message;
// dr1[1] = "None";
// dt.Rows.Add(dr);
ds.Tables[0].Rows.Add(dr);
return ds;
. ds.Tables[0].Columns.Add("ErrMessage", typeof(string));
//DataTable dt = new DataTable();
//dt.Columns.Add("Remark", typeof(string));
//dt.TableName = "Table1";
//dt.Columns.Add("FixName", typeof(string));
DataRow dr = ds.Tables[0].NewRow();
dr[0] = err.Message;
// dr1[1] = "None";
// dt.Rows.Add(dr);
ds.Tables[0].Rows.Add(dr);
return ds;
2.遍历
foreach(DataTable dt in dataSet.Tables)
foreach(DataRow dr in dt.Rows)
foreach(DataColumn dc in dr.Table.Columns)
Console.WriteLine(dr[dc]);
foreach(DataRow dr in dt.Rows)
foreach(DataColumn dc in dr.Table.Columns)
Console.WriteLine(dr[dc]);