根据输入检索行
public void RemoveTask(int index) {
SQL = "DELETE FROM Task where (...) = " +index;
dbConn.Open();
dbCommand = new SqlCeCommand(SQL, dbConn);
dbCommand.ExecuteNonQuery();
dbConn.Close();
}
我想要做的是根据指定行号的索引删除记录,但我不知道应该使用什么函数或变量(注意空白),我尝试了类似 rowNum 的方法,但它不起作用。
任何帮助将不胜感激
public void RemoveTask(int index) {
SQL = "DELETE FROM Task where (...) = " +index;
dbConn.Open();
dbCommand = new SqlCeCommand(SQL, dbConn);
dbCommand.ExecuteNonQuery();
dbConn.Close();
}
What i want to do is to delete the record based on the index which specified the row number but I don't know what function or variable should be used ( note the blank ), i try something like rowNum but it does not work.
any help will be appreaciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前尚不完全清楚您要做什么。我认为以下代码就是您想要的 - 它根据主键删除一行,在这种情况下,主键列的名称是 TaskId (但您可以根据表列名称更改它)。
请注意,它还使用参数化 SQL,从而提供更好的性能和安全性。
It isn't entirely clear what you are trying to do. I think the following code is what you are after - it deletes a row based on the primary key where in this case the name of the primary key column is TaskId (but you can change that based on your table column names).
Note that it also uses parameterised SQL which gives better performance and security.