Today, I tried to solve the problem of mismatched parameter types when using oledb to access the database when I was developing the poetry website some time ago. I wrote several examplesCodeAnd consulted related networksArticleThe problem is not found here.
First, I use reflection to automatically generate oledbparameter Based on the object. The data type will certainly not be abnormal ...... Second, after I splice SQL statements, the data type is correct, which is correct.
The above are all nonsense! The real dry goods are: oledbparameter is executed in the order of appearance rather than the name. Reference a netizen: Maybe not a bug... but it still sucks!
There are two solutions to this problem. One is to splice an SQL string, and the other is to write parameters in order. The second one is recommended to prevent SQL injection to a certain extent.