c# - 如何在 sqlite 中使用 WHERE 语句
问题描述
我已经得到了 sqlite 查询来删除数据库中的条目,单击按钮现在一切正常,我不需要最后有第二个 WHERE 语句。毫无疑问,我需要稍微清理一下我的代码,但我只是想确保它首先工作
private void btn_Delete_Click(object sender, EventArgs e)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this account?", "Confirm Delete", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
connAccount.Open();
using (SQLiteCommand cmd = connAccount.CreateCommand())
{
// adds customers details to the database
cmd.CommandText = @"DELETE FROM account WHERE accid = '" + Global.selectedAccountID.ToString() + "';";
MessageBox.Show("Account Deleted", "Account Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
cmd.ExecuteNonQuery();
connAccount.Close();
}
}
if(dialogResult == DialogResult.No)
{
}
if (cb_active.SelectedIndex == 0)
{
active();
}
if (cb_active.SelectedIndex == 1)
{
inactive();
}
else
{
showAccounts();
}
cb_active.SelectedIndex = -1;
connAccount.Close();
}
解决方案
请检查deleteQuery的值是否正确如下:
- 复制 deleteQuery 的值
- 将值(一个 SQL 脚本)粘贴到 SSMS 中
- 在 SSMS 中执行 SQL 脚本并检查它是否运行没有任何错误。
推荐阅读
- pine-script - RSI 策略 - 策略问题。进入/退出
- html - 第二行长链接掉线
- angular - 在 Angular 8 中动态加载外部脚本
- python - 如何在炬管张量中交换轴?
- amazon-s3 - 从 Glacier 迁移到 S3 Glacier Deep Archive
- linux - 复制所有子目录的递归文件
- microsoft-edge - 终端服务器\Citrix 已发布应用程序中的同步问题
- circuits-framework - Circuits v3.2 Manager.py **events.effects** 问题
- regex - 正则表达式匹配管道之间没有子字符串
- android - 如何在位图变量中获取具有实际大小的位图,而与我使用的设备无关