TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
chronics
NA
4
0
primary keys
May 7 2007 6:08 PM
When i use the code below to add a datarelation to 2 tables named 'Category' and 'Product' and then try to find a row within the tables using the find method shown below I get the error 'Table doesnt have a Primary Key'. DataRelation catAndProdDataRelation = new DataRelation("CategoryAndProductDataRelation", ds.Tables["Category"].Columns[0] , ds.Tables["Product"].Columns[3], true); ds.Relations.Add(catAndProdDataRelation); DataRow cdr = ds.Tables["Category"].Rows.Find(id); I have also tried adding the primary keys explicitly with ds.Tables["Category"].Constraints.Add("PK_ColumnID", ds.Tables["Category"].Columns[0], true); ds.Tables["Product"].Constraints.Add("PK_ProductID", ds.Tables["Product"].Columns[0], true); I get the error constraint matches constraint 1 already in collection I thought the datarelation created the primary keys and the constraint matches error seems to indicate that. Any help much appreciated
Reply
Answers (
2
)
global dataset?
How to get number of records in the database using recordset