我存储的过程如下:
ALTER PROC pr_Update_Users_Nomination
(
@UserID AS VARCHAR(100),
@Nominated AS BIT
)
AS
UPDATE User
SET isNominated = @Nominated
WHERE
EMPID = @UserID;
我想从 c# 代码调用这个过程:下面是我正在尝试的代码:
void OpenConnection()
{
string Nominated = "False";
//Connection String
string sConnString = System.Configuration.ConfigurationManager.ConnectionStrings["ConString1"].ConnectionString;
SqlConnection mySqlCon = new SqlConnection(sConnString);
SqlCommand mySqlCom = mySqlCon.CreateCommand();
//Call the stored proc and provide in parameters
mySqlCom.CommandText = "EXECUTE pr_Update @UserID @Nominated";
mySqlCom.Parameters.Add("@UserID", SqlDbType.VarChar, 20).Value = UserID;
mySqlCom.Parameters.Add("@Nominated", SqlDbType.Bit).Value = Nominated;
mySqlCon.Open();
mySqlCom.ExecuteNonQuery();
mySqlCon.Close();
}
我收到一条错误消息
Incorrect Syntax near @Nominated