我正在尝试更新 SQL 中的列,但出现此错误..
代码:
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();
关于c# - 将 varchar 值 '@a' 转换为数据类型 int 时转换失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42634687/