still no deal... it works once when -1 is not in the database, but the
I can query the dataset to find the max ID and deal with it that way. Just
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:usHyr7NYEHA.3420@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> Just set a negative seed and step, -1 and -1.
> When you update the table in database you (adapter) should update pk-s
with
> real value.
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> miha at rthand com
>
www.rthand.com >
> "shalafi" <jack@bone.com> wrote in message
> news:%23k5g0uJYEHA.3716@TK2MSFTNGP10.phx.gbl...
> > Hi all... got a quick question.
> >
> > I read in XML to a application dataset variable. since i dont have
access
> > to SQL server i decided to avoid Access and go strait to XML.
> >
> > Problem i'm having is that when adding a new row i get a constraint
issue.
> >
> > I havent found how to get the PK stored in XML to the point the dataset
> > recognizes so i do the following after the XML load.
> >
> > x[0] = theDataStore.Tables["tblArticles"].Columns["ArticleID"];
> > x[0].AutoIncrement = true;
> > x[0].AutoIncrementSeed = 0;
> > x[0].AutoIncrementStep = 1;
> > theDataStore.Tables["tblArticles"].PrimaryKey = x;
> >
> > When i try a "newrow()" i get the following.
> >
> > Column 'ArticleID' is constrained to be unique. Value '1' is already
> > present.
> >
> > I didnt get this when i added articleID 1, or when i did articleID 0...
> but
> > it seems that the dataset object doesnt see that ArticleID 1 is already
in
> > the DataSet...
> >
> > Here is the insert code...
> >
> > public zArticle addArticle(int UserID, int CategoryID)
> > {
> > DataRow DR;
> > zArticle theArticle;
> >
> > DR = theDataStore.Tables["tblArticles"].NewRow();
> > DR["UserID"] = UserID;
> > DR["CategoryID"] = CategoryID;
> > DR["Headline"] = "";
> > DR["Body"] = "";
> > DR["Date"] = DateTime.Now.ToString();
> >
> > theArticle = new zArticle(int.Parse(DR["ArticleID"].ToString()),
> > int.Parse(DR["UserID"].ToString()),
> > int.Parse(DR["CategoryID"].ToString()),
> > DR["Headline"].ToString(),
> > DR["Body"].ToString(),
> > (DateTime) DR["Date"]);
> > theArticle.update += new zArticle.updateObject(this.updateArticle);
> >
> > theDataStore.Tables["tblArticles"].Rows.Add(DR);
> > saveDataStore();
> > return theArticle;
> > }
> >
> >
> >
> >
>
>