Home All Groups Group Topic Archive Search About
Author
16 Aug 2006 1:26 PM
Adrian
Im am trying to create an auto increment column in a table.
Where in the code below, should I make which changes
in order to do that?

Adrian

                /*
                dt.Columns.Add("Key", System.Type.GetType("System.Int32"));
                dt.Columns["Key"].AutoIncrement = true;
                dt.Columns["Key"].AutoIncrementSeed = 1;
                dt.Columns["Key"].AutoIncrementStep = 1;
                dt.PrimaryKey = new DataColumn[] { dt.Columns["Key"]};
                 */

                DataColumn auto = dt.Columns.Add("Key", typeof(int));
                dt.Columns["Key"].AutoIncrement = true;
                dt.Columns["Key"].AutoIncrementSeed = 1;
                dt.Columns["Key"].AutoIncrementStep = 1;

                //auto.AutoIncrement = true;
                //auto.AutoIncrementSeed = 0;
                //auto.AutoIncrementStep = 15;

                dt.PrimaryKey = new DataColumn[] {auto};

                dt.Columns.Add("ForeName",
System.Type.GetType("System.String"));
                dt.Columns.Add("LastName",
System.Type.GetType("System.String"));
                dt.Columns.Add("TelephoneNumber",
System.Type.GetType("System.String"));

Author
16 Aug 2006 2:33 PM
Adrian
I have sorted out the proplem.
Thanks,
Adrian.

AddThis Social Bookmark Button