Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Urgent question about Updates

Urgent question about Updates

Scheduled Pinned Locked Moved C#
databasehelpquestioncsharpvisual-studio
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nidhelp
    wrote on last edited by
    #1

    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!

    C 1 Reply Last reply
    0
    • N nidhelp

      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!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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++

      N 1 Reply Last reply
      0
      • C Christian Graus

        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++

        N Offline
        N Offline
        nidhelp
        wrote on last edited by
        #3

        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!

        C 1 Reply Last reply
        0
        • N nidhelp

          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!

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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++

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups