0
當我嘗試將參數用於我的sql語句時出現此錯誤,但在不使用它時正常工作。我的代碼如下所示:vb.net - 對象引用未設置爲對象的實例
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
評論,它工作正常。任何想法?