文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>创建datatable

创建datatable

时间:2011-05-27  来源:解磊

 private DataTable CreateTable()
    {
        DataTable dt = new DataTable("dirName");
        #region table column
        DataColumn columnID = new DataColumn(); //创建一列
        columnID.DataType = System.Type.GetType("System.Int32"); //数据类型
        columnID.ColumnName = "ID"; //列名
        columnID.AutoIncrement = true; //自动递增ID号
        dt.Columns.Add(columnID);  //添加到table  本文来自织梦
        DataColumn columnName = new DataColumn();
        columnName.DataType = System.Type.GetType("System.String");
        columnName.ColumnName = "Name";
        dt.Columns.Add(columnName);
        DataColumn fullName = new DataColumn();
        fullName.DataType = System.Type.GetType("System.String");
        fullName.ColumnName = "fullName";
        dt.Columns.Add(fullName);
        DataColumn cTime = new DataColumn();  本文来自织梦
        cTime.DataType = System.Type.GetType("System.String");
        cTime.ColumnName = "CreateDate";
        dt.Columns.Add(cTime);
        DataColumn type = new DataColumn();
        type.DataType = System.Type.GetType("System.String");
        type.ColumnName = "type";
        dt.Columns.Add(type);
        DataColumn exName = new DataColumn();
        exName.DataType = System.Type.GetType("System.String"); 


 //基于所有创建的数据库架构添加行
        DataRow newRow;//声明一个新行
        newRow = tblBugs.NewRow();
        newRow["Product"] = 1;
        newRow["Version"] = "0.1";
        newRow["Description"] = "Crashes on load";
        newRow["Reporter"] = 5;
        tblBugs.Rows.Add(newRow);
        newRow = tblBugs.NewRow();
        newRow["Product"] = 1;
        newRow["Version"] = "0.1";
        newRow["Description"] = "Does not report correct owner of bug";
        newRow["Reporter"] = 5;
        tblBugs.Rows.Add(newRow);

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载