private void button1_Click(object sender, EventArgs e)
{
using (SQLiteConnection con = new
SQLiteConnection(connectionstring))
{
SQLiteCommand cmd = new SQLiteCommand(connectionstring);
string CMM = "INSERT INTO ALARM (ALARM_ID, ALARM ) SELECT
1,'TEMP' WHERE NOT EXISTS(SELECT FLAG FROM ALARM WHERE FLAG = 0)";
cmd.CommandText = CMM;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
}
我在“SELECT”附近收到此错误:语法错误我无法解决此问题。这个查询在sqlite浏览器中运行正常。请帮助我提前谢谢
答案 0 :(得分:1)
您的查询似乎错过了from
,您可以从中获取数据:
INSERT INTO ALARM (ALARM_ID, ALARM )
SELECT 1,'TEMP'
FROM somehwere -- you where missing this.
WHERE NOT EXISTS(SELECT FLAG FROM ALARM WHERE FLAG = 0)
或者您只想插入一组值:
INSERT INTO ALARM (ALARM_ID, ALARM )
VALUES (1, 'TEMP')