2
If the data from figure 1 to figure 2, reoccupy a TableAdapter. The Update would be a violation of the PRIMARY KEY constraints, can't insert duplicate values
I think it is because the database in the change ID=10 to ID=11, ID=11 the line has not changed in ID=12, is there a way to solve this problem?
CodePudding user response:
In database design, once the primary key generation, generally no longer changes, so are not open to the user to change, you consider to change the user interface,CodePudding user response:
A primary key is not can't change, can change, now is because the value is not a duplicate, so an errorCodePudding user response:
1. Do not recommend using constraints in the database, can lead to abnormal data lock, has the above situation, the back-end logic can be used to control the key constraints,2. The solution - the weak constraint, the way don't constraint, the two try to set up the primary key of the foreign key, do not use strong constraint method to process the data, test time is not convenient, go up, the basic will not adopt the way of directly modify data in the database to handle,
Supplement: delete constraints, again through the program to write data, won't appear this problem,
If you must, it is not recommended to modify data in the database directly,
CodePudding user response: