且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

数据库 Command 对象的参数顺序真的很重要吗?

更新时间:2023-09-15 23:38:10

在 Access 中,ADODB.Command 对象会忽略参数名称.事实上,我可以使用虚假名称(它甚至不存在于 SQL 语句中)来引用参数,而 ADO 并不关心.它似乎只关心您以完全相同的顺序提供参数值,因为这些参数出现在 SQL 语句中.顺便说一句,如果我使用 ? 占位符而不是命名参数构建 SQL 语句,也会发生这种情况.

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.

虽然我意识到您的问题是关于 c# 和 OleDbCommand,但在我看来,Dot.Net 的 OleDbCommand 可能与 Access 的 ADODB 操作相同.命令.不幸的是,我不知道 Dot.Net ……但这是我的直觉.:-)

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. :-)