hello !
i have the following code:
private void setActivated(bool activationB, string user)
{
SqlConnection conn = new SqlConnection(GetConnectionString());
string sql = "UPDATE NannyUsers SET activationB = @activationB WHERE username = @user";
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@activationB", SqlDbType.Bit).Value = activationB;
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Insert Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
conn.Close();
}
}
it returns the following error:
Insert Error:Must declare the scalar variable "@user"
i cant understand why or how to fix it and i spent an entire hour serching for answears online... anny would be highly appreciated!