zoukankan      html  css  js  c++  java
  • 修改已有数据的Datatable的列的类型

    private DataTable UpdateDataTable(DataTable argDataTable)
    {
    DataTable dtResult = new DataTable();
    //克隆表结构
    dtResult = argDataTable.Clone();
    foreach (DataColumn col in dtResult.Columns)
    {
    switch (col.ColumnName)
    {
    case "钢束编号":
    col.DataType = typeof(int);
    break;
    case "X1":
    col.DataType = typeof(float);
    break;
    case "Y1":
    col.DataType = typeof(float);
    break;
    case "X2":
    col.DataType = typeof(float);
    break;
    case "Y2":
    col.DataType = typeof(float);
    break;
    case "半径":
    col.DataType = typeof(float);
    break;
    case "钢束面积":
    col.DataType = typeof(float);
    break;
    case "孔道面积":
    col.DataType = typeof(float);
    break;
    case "根数":
    col.DataType = typeof(int);
    break;
    default:break;

    }

    }
    foreach (DataRow row in argDataTable.Rows)
    {
    DataRow rowNew = dtResult.NewRow();
    rowNew["钢束编号"] = row["钢束编号"];
    //修改记录值
    rowNew["X1"] = row["X1"];
    rowNew["Y1"] = row["Y1"];
    rowNew["X2"] = row["X2"];
    rowNew["半径"] = row["半径"];
    rowNew["钢束面积"] = row["钢束面积"];
    rowNew["孔道面积"] = row["孔道面积"];
    rowNew["根数"] = row["根数"];
    dtResult.Rows.Add(rowNew);
    }
    return dtResult;
    }

  • 相关阅读:
    如何追MM?
    梦里蓝天
    数据仓库USEFUL LINKS(不断更新中)
    The day of blog
    Data Warehouse Architectures in an Internet Age
    数据仓库的数据存储 [转]
    阿里汉的7宗罪
    数据仓库中的一些争议之我见(一)
    java 字符串替换,分割基础
    java 时间比较随笔
  • 原文地址:https://www.cnblogs.com/gilgamos/p/10115195.html
Copyright © 2011-2022 走看看