Patrice
Mon Mar 06 03:20:25 CST 2006
And make sure you don't do call NewRow twice...
--
"Miha Markic [MVP C#]" <miha at rthand com> a écrit dans le message de
news:exLhHyPQGHA.2628@TK2MSFTNGP15.phx.gbl...
> Hi,
>
> You should use negative values for Auto*. This way they won't interfere
with
> database generated values and you can immediately spot new row.
> project_ID.AutoIncrementSeed = -1;
> project_ID.AutoIncrementStep = -1;
>
>
> --
> Miha Markic [MVP C#]
> RightHand .NET consulting & development www.rthand.com
> Blog:
http://cs.rthand.com/blogs/blog_with_righthand/
>
> "deko" <deko@nospam.com> wrote in message
> news:kvidnfkWfuW2cZbZ4p2dnA@comcast.com...
> >I create a DataSet called database and add a table to it as shown below.
> >Why does the AutoIncrement value advance by 2 every time I add a record?
> >How do I get it to advance by 1?
> >
> > DataTable tblProject = database.Tables.Add("TableProject");
> > DataColumn project_ID = tblProject.Columns.Add("Project_ID",
> > typeof(Int32));
> > project_ID.AllowDBNull = false;
> > project_ID.Unique = true;
> > project_ID.AutoIncrement = true;
> > project_ID.AutoIncrementSeed = 1;
> > project_ID.AutoIncrementStep = 1;
> > tblProject.PrimaryKey = new DataColumn[] { tblProject.Columns[0] };
> >
> > //other columns added here...
>
>