以下是我的代码:
no
我收到以下错误:
必须声明标量变量“@BenchID”。
答案 0 :(得分:0)
我做了很多追踪和错误,找到了解决问题的方法。答案是SQL Server 2008 R2,我正在使用它,不支持命名参数。这就是错误的原因。
我必须更改我的代码,如下所示:
If cls.UserID = 0 Then
sql = "INSERT INTO Tabusers ("
sql &= " BenchID,"
sql &= " UserType,"
sql &= " UserName,"
sql &= " Password,"
sql &= " Status,"
sql &= " LastInTime,"
sql &= " LastOutTime"
sql &= ") VALUES ("
sql &= " ?,"
sql &= " ?,"
sql &= " ?,"
sql &= " ?,"
sql &= " ?,"
sql &= " ?,"
sql &= " ?"
sql &= " )"
然后它奏效了。谢谢大家的建议。