我试图从我的数据库中删除一行,
这是我的代码:
sql = "delete sum_lines from sum_lines join sum_tbl on sum_lines.summary_id = sum_tbl.id where sum_tbl.user_id = @userId and sum_lines.line_id ='@lineId'";
SqlConnection con = new SqlConnection(conString);
dataObj = new DataObj();
SqlCommand com = new SqlCommand(sql, con);
com.Parameters.Add(new SqlParameter("@userId", userId));
com.Parameters.Add(new SqlParameter("@lineId", lineId));
con.Open();
com.ExecuteNonQuery();
con.Close();
Run Code Online (Sandbox Code Playgroud)
问题是,如果我在管理工具中尝试我的sql语句,它就能完美运行.但是当我的代码运行时它不会对我的数据库产生影响.
它去了这个代码,我可以在我的调试模式中看到,但它不会因某些原因而影响.任何输入?
删除单引号'@lineId'.使用引号,您@lineid在第二个条件中指定值等于string.