c# - 删除行的SQL代码?

标签 c# sql sql-server

请任何人向我解释以下代码为什么没有删除表格行的问题。

con.Open();
SqlCommand cmd = new SqlCommand("delete from RentTable where CID = '" + ID + "' and MID = '" + MID + "' )", con);
int result = cmd.ExecuteNonQuery();
if (result == 1)
{
    Message = "succsess";
}
else
{
    Message = "!";
}
con.Close();

最佳答案

如果人们首先将他们的查询加载到一个字符串变量中,然后将它们打印出来用于调试目的,那么所有这些类型的问题中的 75% 将得到解决:-)

您在查询末尾有一个右括号 ),这不应该出现。

关于c# - 删除行的SQL代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18925682/

相关文章:

c# - 什么是 DbGeography 返回距离单位?

c# - 加快在 WPF 中将对象添加到 Canvas

mysql - 使用 SQL 清除非字母数字值

sql-server - SQL Server、nvarchar(MAX) 或 ntext、image 或 varbinary?

python - pyodbc 无法连接到数据库

c# - 使用 Microsoft Graph 从日历中删除日期范围内的许多事件和某个扩展属性值

java - 处理未使用的 return 语句

sql - Liftweb - 使用映射器获取 SQL 表字段的最大值

sql - 如何在 Laravel 中进行 self 连接,从而产生不同的值

java - hibernate : All tables in SQL Server database are not auto-created