如何在webmatrix中使用onduplicate密钥更新 [英] How to use the onduplicate key update in webmatrix

查看:63
本文介绍了如何在webmatrix中使用onduplicate密钥更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个表格,我在webmatrix上使用重复键更新mysql语法,但它似乎没有工作。我收到此错误消息。



解析查询时出错。 [令牌行号= 1,令牌行偏移= 71,令牌错误= ON]



这里是我的代码,我不知道wat am做错了..





hello guys,i have a form where am using the on duplicate key update mysql syntax in webmatrix but it doesnt seem to work. i get this error message instead.

There was an error parsing the query. [ Token line number = 1,Token line offset = 71,Token in error = ON ]

here is my code below,i dont know wat am doing wrong..


var save = "insert into registration(student_number,email) VALUES(@0,@1)" +" ON DUPLICATE KEY UPDATE student_number=@0,email=@1";
     db.Execute(save,number,email);





代码似乎更正,但没有运行



the code seems correc but doesnt run

推荐答案

尝试使用

try with
var save = "insert into registration(student_number,email) VALUES(@0,@1) ON DUPLICATE KEY UPDATE email=VALUES(@1)";
db.Execute(save,number,email);


这篇关于如何在webmatrix中使用onduplicate密钥更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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