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