且构网

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

VB.NET - 为什么这个 sql 命令作为字符串而不是参数化查询工作?

更新时间:2023-11-30 22:58:46

尽管 OLEDB 类可以使用命名参数,但它实际上只是使用了一个?"标记在背景中,因此参数按 INDEX 顺序排列.您的 sql 在 Subsp 变量之前出现了 ID 变量.

Despite the fact that the OLEDB class can use named parameters, it is actually just using a '?' marker in the background, so the parameters are in INDEX order. Your sql has the ID variable occurring before the Subsp variable.

切换它,像这样:

For Each match As Long In choices
 command_sbsp.Parameters.Clear()
 command_sbsp.Parameters.AddWithValue("@ID", match)
 command_sbsp.Parameters.AddWithValue("@Subsp", word)