SQL Access ON DUPLICATE KEY UPDATE [英] SQL Access ON DUPLICATE KEY UPDATE

查看:83
本文介绍了SQL Access ON DUPLICATE KEY UPDATE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行此SQL语句时没有问题:

When I run this SQL statement there is no problem:

cmd = new OleDbCommand("INSERT INTO TableComments (Event, Date, Comment) VALUES (@event, @date, @comment);

但是当添加最后一部分ON DUPLICATE KEY UPDATE:

But when adding the last part ON DUPLICATE KEY UPDATE:

cmd = new OleDbCommand("INSERT INTO TableComments (Event, Date, Comment) VALUES (@event, @date, @comment) ON DUPLICATE KEY UPDATE Comment = VALUES(@comment)", connection);

然后我收到错误:

'在SQL语句结束时缺少分号(;)。

'Missing semicolon (;) at end of SQL statement.'

可能出现什么问题?

我真的需要  ON DUPLICATE KEY UPDATE部分,因为SQL语句在一个计时器内,我最终得到了很多新行而不是让他们更新。

I really need the ON DUPLICATE KEY UPDATE part, because the SQL Statement is within a timer and I end up with a lots of new rows instead of having them updated.

推荐答案

Hi Jinas,

Hi Jinas,

>>可能出现什么问题?

>>What could be wrong?

请在sql语句的末尾添加分号:

Please add a semicolon at the end of the sql statement:

cmd = new OleDbCommand("INSERT INTO TableComments (Event, Date, Comment) VALUES (@event, @date, @comment) ON DUPLICATE KEY UPDATE Comment = VALUES(@comment);", connection);


 

希望有所帮助!

 

Hope it helps!

最好的问候,

Stanly


这篇关于SQL Access ON DUPLICATE KEY UPDATE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆