• DataTable


    方法一:

    DataTable  tblDatas = new DataTable("Datas");
    DataColumn dc = null;
    dc = tblDatas.Columns.Add("ID", Type.GetType("System.Int32"));
    dc.AutoIncrement = true;//自动增加
    dc.AutoIncrementSeed = 1;//起始为1
    dc.AutoIncrementStep = 1;//步长为1
    dc.AllowDBNull = false;//

    dc = tblDatas.Columns.Add("Product", Type.GetType("System.String"));
    dc = tblDatas.Columns.Add("Version", Type.GetType("System.String"));
    dc = tblDatas.Columns.Add("Description", Type.GetType("System.String"));

    DataRow newRow;
    newRow = tblDatas.NewRow();
    newRow["Product"] = "水果刀";
    newRow["Version"] = "2.0";
    newRow["Description"] = "打架专用";
    tblDatas.Rows.Add(newRow);

    newRow = tblDatas.NewRow();
    newRow["Product"] = "折叠凳";
    newRow["Version"] = "3.0";
    newRow["Description"] = "行走江湖七武器之一";
    tblDatas.Rows.Add(newRow);

    方法二:

     DataTable tblDatas = new DataTable("Datas");
    tblDatas.Columns.Add("ID", Type.GetType("System.Int32"));
    tblDatas.Columns[0].AutoIncrement = true;
    tblDatas.Columns[0].AutoIncrementSeed = 1;
    tblDatas.Columns[0].AutoIncrementStep = 1;

    tblDatas.Columns.Add("Product", Type.GetType("System.String"));
    tblDatas.Columns.Add("Version", Type.GetType("System.String"));
    tblDatas.Columns.Add("Description", Type.GetType("System.String"));

    tblDatas.Rows.Add(new object[]{null,"a","b","c"});
    tblDatas.Rows.Add(new object[] { null, "a", "b", "c" });
    tblDatas.Rows.Add(new object[] { null, "a", "b", "c" });
    tblDatas.Rows.Add(new object[] { null, "a", "b", "c" });
    tblDatas.Rows.Add(new object[] { null, "a", "b", "c" });

  • 相关阅读:
    Java基础知识(一)环境变量的设置、变量与常量、自动类型转换、自增长、赋值运算符
    ModelState
    DOM
    正则表达式常见形式
    通过JS设置一个元素的文本
    JS(三) 原型对象与原型链
    JS(二)call方法和apply方法
    第四周学习进度表
    敏捷开发方法综述
    数组02
  • 原文地址:https://www.cnblogs.com/dodui/p/1917297.html
Copyright © 2020-2023  润新知