By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,081 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,081 IT Pros & Developers. It's quick & easy.

Identity issues with dataset

P: n/a
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

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()),
(DateTime) DR["Date"]);
theArticle.update += new zArticle.updateObject(this.updateArticle);

return theArticle;
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.