Urgent question about Updates
-
Hi I have 4 fields as my pk in access db.. I query for data in VS.NET 2003. I query by id AND pwd.. I can view the data in datagrid, but not update properly. When i update it says: The changes you requested to the table were not successful because they would create duplicate values in the index, pk, or relationship. Change the data in the field or fields that contain duplicated data, remove the index, or redefine the index to permit duplicate entries and try again. I tried to solve the problem by going to access db and changed the 'Indexed' properties (of the 4 fields i used as my pk) from 'No' to 'Yes (Duplicates OK)'. but still i get the same error when i edit values in datagrid and click on update. Something puzzling is, when i click on view button after i update, i can see the latest AND first updated entry in my datagrid and access db. The previously edited data is changed back to the original value again. so what im saying is, eg. row1) 4 row2) 4 row3) 4 I changed row2) from 4 to 5 and press update. the error msg is shown. then, i press View button. i see: row1) 4 row2) 5 row3) 4 Now i change row3) from 4 to 3. again, error is shown. now i see: row1) 4 row2) 4 row3) 3 I tried playing with it, i update both row1) and row2) at the same time. I changed row1) to 5 and row2) to 6 and i see: row1) 5 row2) 4 row3) 4 What's happening and what must i do exactly?? Please help asap. Thank you!
-
Hi I have 4 fields as my pk in access db.. I query for data in VS.NET 2003. I query by id AND pwd.. I can view the data in datagrid, but not update properly. When i update it says: The changes you requested to the table were not successful because they would create duplicate values in the index, pk, or relationship. Change the data in the field or fields that contain duplicated data, remove the index, or redefine the index to permit duplicate entries and try again. I tried to solve the problem by going to access db and changed the 'Indexed' properties (of the 4 fields i used as my pk) from 'No' to 'Yes (Duplicates OK)'. but still i get the same error when i edit values in datagrid and click on update. Something puzzling is, when i click on view button after i update, i can see the latest AND first updated entry in my datagrid and access db. The previously edited data is changed back to the original value again. so what im saying is, eg. row1) 4 row2) 4 row3) 4 I changed row2) from 4 to 5 and press update. the error msg is shown. then, i press View button. i see: row1) 4 row2) 5 row3) 4 Now i change row3) from 4 to 3. again, error is shown. now i see: row1) 4 row2) 4 row3) 3 I tried playing with it, i update both row1) and row2) at the same time. I changed row1) to 5 and row2) to 6 and i see: row1) 5 row2) 4 row3) 4 What's happening and what must i do exactly?? Please help asap. Thank you!
nidhelp wrote: I tried to solve the problem by going to access db and changed the 'Indexed' properties (of the 4 fields i used as my pk) from 'No' to 'Yes (Duplicates OK)'. but still i get the same error when i edit values in datagrid and click on update. You should fix your code, not hack your database. You're trying to change an index to be a value that already exists. You should not change index values at all, that is what they are for. Christian Graus - Microsoft MVP - C++
-
nidhelp wrote: I tried to solve the problem by going to access db and changed the 'Indexed' properties (of the 4 fields i used as my pk) from 'No' to 'Yes (Duplicates OK)'. but still i get the same error when i edit values in datagrid and click on update. You should fix your code, not hack your database. You're trying to change an index to be a value that already exists. You should not change index values at all, that is what they are for. Christian Graus - Microsoft MVP - C++
ok... so do u mean i should change 'Indexed' back to 'No' for all of the 4 fields? please pardon me, but where and how do i change my codes? here's how i got my data to show in datagrid: i used the VS.net dataform wizard to generate dataadapter and dataset... then i go to configure dataadapter and add in the Where clause... i mananged to query by id and pwd, but cant update properly... i already generated all the commands successfully using oledbadapter... i donno where's wrong and what to change... please help me... it's urgent... thankful for your advice!
-
ok... so do u mean i should change 'Indexed' back to 'No' for all of the 4 fields? please pardon me, but where and how do i change my codes? here's how i got my data to show in datagrid: i used the VS.net dataform wizard to generate dataadapter and dataset... then i go to configure dataadapter and add in the Where clause... i mananged to query by id and pwd, but cant update properly... i already generated all the commands successfully using oledbadapter... i donno where's wrong and what to change... please help me... it's urgent... thankful for your advice!
nidhelp wrote: ok... so do u mean i should change 'Indexed' back to 'No' for all of the 4 fields? No, I mean if you create an index column, then it should be an identity, set by the database, not by you. And you should never change it. Personally, I think the wizards for generating dataadapters are crap, you should just write your own SQL code in a database layer in your app. Christian Graus - Microsoft MVP - C++