Is order of parameters for database Command object really important?

后端 未结 3 977
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 02:46

I was debugging a database operation code and I found that proper UPDATE was never happening though the code never failed as such. This is the code:

               


        
3条回答
  •  无人及你
    2020-12-04 03:22

    Within Access, an ADODB.Command object ignores parameter names. In fact I can refer to a parameter using a bogus name (which doesn't even exist in the SQL statement) and ADO doesn't care. All it seems to care about is that you supply parameter values in the exact same order as those parameters appear in the SQL statement. BTW, that is also what happens if I build the SQL statement with ? place-holders instead of named parameters.

    While I realize that your question is about c# and OleDbCommand, it looks to me like Dot.Net's OleDbCommand may be operating the same as Access' ADODB.Command. Unfortunately, I don't know Dot.Net ... but that is my hunch. :-)

提交回复
热议问题