saimisei

datatable 生成自动增长列的方法

  DataSet ds = SelectSqlDS(sql);//SQL生成一个dataset

        DataColumn column = new DataColumn();
        column.DataType = System.Type.GetType("System.Int32");
        column.ColumnName = "SequenceNumber";
        column.AutoIncrement = true;
        column.AutoIncrementSeed = 1;
        column.AutoIncrementStep = 1;
        DataTable table = new DataTable("table");
        table.Columns.Add(column);
        DataTableReader dataTableReader = new DataTableReader(ds.Tables[0]);
        table.Load(dataTableReader);
        return table.DefaultView;

posted on 2008-07-29 16:22  閑雲野鶴  阅读(608)  评论(0编辑  收藏  举报

导航