为什么我会收到错误消息Must declare the scalar variable "@ChargeRate"
?
public static void InsertSqlSerwer2(BatteryFullInfo info)
{
SqlConnection MSDEconn;
MSDEconn = new SqlConnection();
MSDEconn.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\HOME\Documents\NewDataBase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
MSDEconn.Open();
string komenda = "INSERT into Battery_Information VALUES (@ChargeRate, @Id, @DischargeRate, @RemainingCapacity, @Voltage, @BatteryLifePercent, @ChargeStatus)";
SqlCommand MSDEcommand = new SqlCommand(komenda, MSDEconn);
MSDEcommand.Parameters.AddWithValue("@ChargeRate", info.ChargeRate);
MSDEcommand.Parameters.AddWithValue("@Id", info.IdBateria);
MSDEcommand.Parameters.AddWithValue("@DischargeRate", info.DischargeRate);
MSDEcommand.Parameters.AddWithValue("@RemainingCapacity", info.RemainingCapacity);
MSDEcommand.Parameters.AddWithValue("@Voltage", info.Voltage);
MSDEcommand.Parameters.AddWithValue("@BatteryLifePercent", info.BatteryLifePercent);
MSDEcommand.Parameters.AddWithValue("@ChargeStatus", info.ChargeStatus);
MSDEcommand.Parameters.Clear();
MSDEcommand.ExecuteNonQuery();
MSDEconn.Close();
}