C# 转换varchar值时转换失败'@a';到数据类型int

C# 转换varchar值时转换失败'@a';到数据类型int,c#,sql,sql-server,entity-framework,C#,Sql,Sql Server,Entity Framework,我正在尝试更新SQL中的列,但出现此错误 代码: 删除@a周围的单引号 SqlConnection cn = new SqlConnection("CONNECTION STRING"); SqlCommand com = new SqlCommand("update details set Available='Yes' where License=@a", cn); com.Parameters.AddWithValue("@a", num);

我正在尝试更新SQL中的列,但出现此错误

代码:


删除@a周围的单引号

SqlConnection cn = new SqlConnection("CONNECTION STRING");
            SqlCommand com = new SqlCommand("update details set Available='Yes' where License=@a", cn);
            com.Parameters.AddWithValue("@a", num);
            cn.Open();
            com.ExecuteNonQuery();
            cn.Close();

删除@a周围的单引号

SqlConnection cn = new SqlConnection("CONNECTION STRING");
            SqlCommand com = new SqlCommand("update details set Available='Yes' where License=@a", cn);
            com.Parameters.AddWithValue("@a", num);
            cn.Open();
            com.ExecuteNonQuery();
            cn.Close();

删除
@a
其中License=@a
周围的单引号,方法是将参数放在单引号中,与作为参数名称而不是参数值的文本字符串进行比较。这就像期望
inti=3;字符串s=“i”
导致
s
为“3”而不是“i”。稍微绕道,但您应该阅读此内容。删除
@a
其中License=@a
周围的单引号,方法是将参数放在单引号中,与作为参数名称而不是参数值的文本字符串进行比较。这就像期望
inti=3;字符串s=“i”
导致
s
为“3”而不是“i”。稍微绕道,但您应该阅读此内容。