/// <summary>
/// 修改数据表DataTable某一列的类型和记录值(正确步骤:1.克隆表结构,2.修改列类型,3.修改记录值,4.返回结果)
/// </summary>
/// <param name="orgDataTable">数据表DataTable</param>
/// <returns>数据表DataTable</returns>
private DataTable UpdateDataTable(DataTable orgDataTable)
{
DataTable dt = new DataTable();
//克隆表结构
dt = orgDataTable.Clone();
foreach (DataColumn col in dt.Columns)//循环列
{
if (col.ColumnName == "Name")
{
//修改列类型
col.DataType = typeof(String);
}
}
foreach (DataRow dr in orgDataTable.Rows)//循环行
{
DataRow newdr = dt.NewRow();
newdr["Account"] = dr["Account"];
newdr["Name"] = dr["Name"];
//修改记录值
newdr["Name"] = ""+dr["Name"];
dt.Rows.Add(newdr);
}
//返回结果
return dt;
}