Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
试图从 sql 数据库中删除行。引号是我试图在以下查询中添加完美引号但它不接受它的问题。
con.Open(); SqlCommand fac = new SqlCommand("delete from faculty where schoolName = '" + schlName , con); fac.ExecuteNonQuery(); con.Close();
请检查并回复解决方案。我试图在以下查询中添加完美的报价,但它不接受它。
您需要使用参数:
using (var conn = ...) using (var command = new SqlCommand("delete from faculty where schoolName = @School", con)) { command.Parameters.AddWithValue("@School", schoolName);