The following problems are easy to ignore, but it is not easy to find out the problem, which makes me a lot of headaches, so here is a summary, also for others! 1. When you run an SQL command in the form of parameters, the parameter array must be exactly the same as the location and name of the parameter name in the SQL statement. Otherwise, the execution fails, but no error is reported. sqlinsertt
The following problems are easy to ignore, but it is not easy to find out the problem, which makes me a lot of headaches, so here is a summary, also for others! 1. when you run an SQL command in the form of parameters, the parameter array must be exactly the same as the location and name of the parameter name in the SQL statement. Otherwise, the execution fails, but no error is reported; SQL = "insert t
The following problems are easy to ignore, but it is not easy to find out the problem, which makes me a lot of headaches, so here is a summary, also for others!
1. When you run an SQL command in the form of parameters, the parameter array must be exactly the same as the location and name of the parameter name in the SQL statement. Otherwise, the execution fails, but no error is reported;
SQL = "insert table (a, B, c) values (@ a, @ B, @ c )"
Params = {@ a, @ c, @ B} ---> This is incorrect.
Params = {@ a, @ B, @ c} ---> This is correct.
2. When the SQL command is executed in the form of parameters, when the field type is time type, you need to explicitly declare the parameter type as Date, not in the form of parameter name + Value
SQL = "update table set editdate = @ dt"
Param = new oledbparameter ("@ dt", DateTime. Now) --> This is an error. An error is reported during execution: the data type in the standard expression does not match
Param = new oledbparameter ("@ dt", OleDbType. Date) {Value = DateTime. Now} --> This is correct
3. Pay attention to the reserved words in the ACCESS database. Do not use these words as field names. If you do need them, add square brackets to show instructions.
SQL = "update user set name = 'xxx'" --> This is incorrect.
SQL = "update [user] set [name] = 'xxx'" --> This is correct and displays non-system reserved words.