Greetings dear c# corner members,
I would like to create a table in my database, where all items can have duplicate values. So I understand to do that, I must not set a primary key for my table. However If I don't set a primary key for my table, I will get the following error each time I try to update my table:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
How can I overcome this problem?
Hope you can help
Ali
Loading

Sam HobbsPosted Apr 9, 2011, 3:49 PM
Mayur GujrathiPosted Apr 9, 2011, 8:31 AM
Ali AlfarajPosted Apr 9, 2011, 8:27 AM
So, I will not set a primary key for my table and I will need to fix this error:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
Any suggestions????
Ali AlfarajPosted Apr 9, 2011, 8:09 AM
Thanks,
Ali
Prabhakar PariharPosted Apr 9, 2011, 6:21 AM
Firstly u decalred prmary key on ur database atble . . then ur duplicasy problem might be slove . .
Ali AlfarajPosted Apr 9, 2011, 5:44 AM
Ali AlfarajPosted Apr 9, 2011, 5:44 AM
Ali AlfarajPosted Apr 9, 2011, 5:43 AM
What do you mean by "fire update query through stored procedure"
CrishPosted Apr 9, 2011, 5:19 AM
- First, run the above GROUP BY query to determine how many sets of duplicate PK values exist, and the count of duplicates for each set.
2.Select the duplicate key values into a holding table.SELECT col1, col2, col3=count(*) INTO holdkey FROM t1 GROUP BY col1, col2 HAVING count(*) > 1
3.SELECT DISTINCT t1.* INTO holddups FROM t1, holdkey WHERE t1.col1 = holdkey.col1 AND t1.col2 = holdkey.col2
4.
SELECT col1, col2, count(*) FROM holddups GROUP BY col1, col2
5.DELETE t1 FROM t1, holdkey WHERE t1.col1 = holdkey.col1 AND t1.col2 = holdkey.col2
6.
Mayur GujrathiPosted Apr 9, 2011, 4:50 AM