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. datagrid update failure

datagrid update failure

Scheduled Pinned Locked Moved C#
questioncsharpdatabasecomhelp
6 Posts 3 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.
  • D Offline
    D Offline
    dorianr
    wrote on last edited by
    #1

    I have a C# windows appliation with an Access database. There are 2 tables: USERS and PERMISSION_TYPES. Table definitions are: Table Name: USERS Fields: First_Name Last_Name Address PERMISSION_TYPE (FK to PERMISSION_TYPES) Table Name: PERMISSION_TYPES Fields: PERMISSTION_TYPE (PK) DESCRIPTION The tables are linked vis the PERMISSION_TYPE field. I can make successful updates to the database, however, I'm trying to use a datagrid for each table so the user can Insert, Update, and Delete records in each table. When the PERMISSION_TYPES.DESCRIPTION field is changed, an error message is returned that states: "The record cannot be deleted or changed because table 'USERS' includes releated records" This doesn't make any sense to me, since the DESCRIPTION field is not a Primary Key, and the updates are successful within Access. I have used the generated Update code, and I have written my own update code - I get the same error message. Does anyone know what is wrong?:( Thanks so much, Randy dorianr@mail.com

    S I 2 Replies Last reply
    0
    • D dorianr

      I have a C# windows appliation with an Access database. There are 2 tables: USERS and PERMISSION_TYPES. Table definitions are: Table Name: USERS Fields: First_Name Last_Name Address PERMISSION_TYPE (FK to PERMISSION_TYPES) Table Name: PERMISSION_TYPES Fields: PERMISSTION_TYPE (PK) DESCRIPTION The tables are linked vis the PERMISSION_TYPE field. I can make successful updates to the database, however, I'm trying to use a datagrid for each table so the user can Insert, Update, and Delete records in each table. When the PERMISSION_TYPES.DESCRIPTION field is changed, an error message is returned that states: "The record cannot be deleted or changed because table 'USERS' includes releated records" This doesn't make any sense to me, since the DESCRIPTION field is not a Primary Key, and the updates are successful within Access. I have used the generated Update code, and I have written my own update code - I get the same error message. Does anyone know what is wrong?:( Thanks so much, Randy dorianr@mail.com

      S Offline
      S Offline
      Sascha Andres
      wrote on last edited by
      #2

      Hi Randy, dorianr wrote: This doesn't make any sense to me, since the DESCRIPTION field is not a Primary Key, and the updates are successful within Access. I have used the generated Update code, and I have written my own update code - I get the same error message. This sounds really a bit strange - just as the line would first be deleted, and later inserted again :confused: I think PERMISSION_TYPES is just a lookup table. Something that helps the user of your program to sort the records in the user table. Personally I prefer not to have the user edit a lookup table side by side of the main table. I do this because:

      • the permission type is linked to more than one line, editing with only one row is usually specific, and lookups should be general
      • On a multi user system not all users should have adminstrator priviledges, eg access to the options. Defining possible permissiontypes (or more general: options)is the admins task

      OK, this does not really solve your problem with the table, but perhaps an other way of doing things might be helpful. Sascha -- http://www.livingit.de http://www.mobile-bookmarks.info

      D 1 Reply Last reply
      0
      • D dorianr

        I have a C# windows appliation with an Access database. There are 2 tables: USERS and PERMISSION_TYPES. Table definitions are: Table Name: USERS Fields: First_Name Last_Name Address PERMISSION_TYPE (FK to PERMISSION_TYPES) Table Name: PERMISSION_TYPES Fields: PERMISSTION_TYPE (PK) DESCRIPTION The tables are linked vis the PERMISSION_TYPE field. I can make successful updates to the database, however, I'm trying to use a datagrid for each table so the user can Insert, Update, and Delete records in each table. When the PERMISSION_TYPES.DESCRIPTION field is changed, an error message is returned that states: "The record cannot be deleted or changed because table 'USERS' includes releated records" This doesn't make any sense to me, since the DESCRIPTION field is not a Primary Key, and the updates are successful within Access. I have used the generated Update code, and I have written my own update code - I get the same error message. Does anyone know what is wrong?:( Thanks so much, Randy dorianr@mail.com

        I Offline
        I Offline
        Ista
        wrote on last edited by
        #3

        that and your violating a relationship issues. I.E.. see FOREIGN KEY RELATIONSHIPS in dbase theory I'm not an expert yet, but I play one at work. Yeah and here too.

        D 1 Reply Last reply
        0
        • S Sascha Andres

          Hi Randy, dorianr wrote: This doesn't make any sense to me, since the DESCRIPTION field is not a Primary Key, and the updates are successful within Access. I have used the generated Update code, and I have written my own update code - I get the same error message. This sounds really a bit strange - just as the line would first be deleted, and later inserted again :confused: I think PERMISSION_TYPES is just a lookup table. Something that helps the user of your program to sort the records in the user table. Personally I prefer not to have the user edit a lookup table side by side of the main table. I do this because:

          • the permission type is linked to more than one line, editing with only one row is usually specific, and lookups should be general
          • On a multi user system not all users should have adminstrator priviledges, eg access to the options. Defining possible permissiontypes (or more general: options)is the admins task

          OK, this does not really solve your problem with the table, but perhaps an other way of doing things might be helpful. Sascha -- http://www.livingit.de http://www.mobile-bookmarks.info

          D Offline
          D Offline
          dorianr
          wrote on last edited by
          #4

          Hi Sascha, I'm wondering if there is a problem with the datagrid in .NET 2003 (I have experienced other bugs, but that is anther story). The two tables that I'm discussing are both lookup table that are in the Administration module (not all users have access). I can solve this problem by adding a numeric, primary key to the PERMISSIONS_TYPE lookup table. I have no idea why using a PK for PERMISSION_TYPE would not let an Administrator update the permission type DESCRIPTION. This solution isn't very feasible, since I'm on the last part of a large project - it would set us back by a lot. Thanks, Randy

          1 Reply Last reply
          0
          • I Ista

            that and your violating a relationship issues. I.E.. see FOREIGN KEY RELATIONSHIPS in dbase theory I'm not an expert yet, but I play one at work. Yeah and here too.

            D Offline
            D Offline
            dorianr
            wrote on last edited by
            #5

            I'm not violating FOREIGN KEY RELATIONSHIPS, since I can perform this update directly in the relational database. The problem seems to be with using .NET 2003. I've run tests, and I can perform the same update within the database, just not via .NET

            I 1 Reply Last reply
            0
            • D dorianr

              I'm not violating FOREIGN KEY RELATIONSHIPS, since I can perform this update directly in the relational database. The problem seems to be with using .NET 2003. I've run tests, and I can perform the same update within the database, just not via .NET

              I Offline
              I Offline
              Ista
              wrote on last edited by
              #6

              Yes but the error is stating that and key is bound on that column there fore if you destroy that field then you will have an invalid key assigned to other records. Access is a crap database and thats why you might have gotten away with it, but SQL does a check on those fields. Its also possible you might be creating relationships with your code but the problem is key relationships defined either in the database table or the dataset table. nick I'm not an expert yet, but I play one at work. Yeah and here too.

              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