The parameterized method is used to update the access database today. No error is returned, but the data is not updated. Later, we found that when access is parameterized, the parameter location must be in the same order as the value assignment. Otherwise, data cannot be updated but no error is reported during the update.
For example, update tablename set [a] = @ a1, [B] = @ a2 where [id] = @ a3
When adding a parameter, you must add @ a, @ B, and @ id. That is, you must
Cmd. Parameters. AddWithValue ("@ a1", );
Cmd. Parameters. AddWithValue ("@ a2", B );
Cmd. Parameters. AddWithValue ("@ a3", id );
If the order is incorrect, it cannot be updated. This is different from SQL server. In SQL server, you do not have to worry about the order in which parameters are added.
Because access does not report bugs when the parameters are misplaced during update, but does not update them, you must pay attention to this when writing programs.
From IT enthusiast Inn