zoukankan      html  css  js  c++  java
  • 修改已有数据的DataTable的字段类型

    //将int类型的字段改为string类型          

    DataTable dtResult = new DataTable();
                dtResult = dt.Clone();
                foreach (DataColumn col in dtResult.Columns)
                {
                   col.DataType = typeof(String);
                }
                for (int i = 0; i < dt.Rows.Count ; i++)
                {
                    DataRow rowNew = dtResult.NewRow();
                    for (int j = 0; j < dt.Columns.Count ; j++)
                    {
                            if (Convert.ToInt32(dt.Rows[i][j]) == 0)
                            {
                                rowNew[j] = "不开考";
                            }
                            else if (Convert.ToInt32(dt.Rows[i][j]) == 1)
                            {
                                rowNew[j] = "开考";
                            }             
                    }
                    dtResult.Rows.Add(rowNew);
                }

  • 相关阅读:
    WPF 快捷键读写txt
    win10 UWP GET Post
    win10 UWP GET Post
    win10 UWP Hmac
    win10 UWP Hmac
    win10 UWP MessageDialog 和 ContentDialog
    MySQL 触发器-更新字段时,status列会加一
    [SDOI2018]旧试题
    win10 UWP MessageDialog 和 ContentDialog
    win10 UWP RSS阅读器
  • 原文地址:https://www.cnblogs.com/hobby0524/p/7122207.html
Copyright © 2011-2022 走看看