Creating a identity column for a Datatable

Posted by Puneet20884 under C# category on | Views : 6434
The sample self explanatory code goes as:

  DataTable dt = new DataTable("News");
DataColumn dc = new DataColumn("id", Type.GetType("System.String")); // Identity Column
dc.AutoIncrement = true;
dc.AutoIncrementSeed = 1;
dc.AutoIncrementStep = 1;
dt.Columns.Add("DateAdded", Type.GetType("System.String"));
dt.Columns.Add("Description", Type.GetType("System.String"));
dt.Columns.Add("OnHome", Type.GetType("System.Boolean"));

Comments or Responses

Login to post response