尝试在我的 sql 语句中使用参数时出现此错误,但不使用时它工作正常。我的代码如下:
Dim i As String
Dim sql as String
sql = "SELECT * FROM tblStaff WHERE Username = @User AND Password = @Pass"
myCommand = New SqlCommand(sql, myConnection)
myCommand.Parameters.AddWithValue("@User", txtUser.Text)
myCommand.Parameters.AddWithValue("@Pass", txtPassword.Text)
i = myCommand.ExecuteScalar
txtUserType.Text = i.ToString
当我评论时txtUserType.Text = i.ToString
,它工作正常。任何想法?