MS-Access中的查询无法通过c#工作 [英] Query In MS-Access doesn't working through c#

查看:96
本文介绍了MS-Access中的查询无法通过c#工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在微软访问中:



In microsoft access:

Update admin_table Set Password  = 'admin1' WHERE Password = 'admin'





任何人都可以解释一下为什么这不起作用?



我写的是上面一行通过c#在wpf但是给定的行不起作用。当同一行通过MS-ACCESS查询设计写入时,它打开弹出窗口说明





Can anyone please explain me why this doesn't work?

I'm writing above line through c# in wpf but given line don't work. When the same line write through MS-ACCESS query Design then it turs to open the pop-up saying

"Once you click Yes, you can't use the undo command to reverse the changes. Are you sure you want to update these records"





点击是的,它改变了值。



And on clicking yes it changes the value.

推荐答案

密码是MS-ACCESS中的关键字。所以你应该用这个命令来更新它。

Password is the keyword in MS-ACCESS. So you should use this command to update it.
UPDATE [admin_table] SET [Password]=? WHERE [Password]=?






Or

UPDATE [admin_table] SET [Password]='admin1' WHERE [Password]='admin'


首先,密码 MS Access中的保留字 [ ^ ]。不要使用它!



如果你还想使用它,你需要用 [] 括号。

First of all, Password is reserved word in MS Access[^]. Do not use it!

In case you still want to use it, you need to aroud it with [] brackets.
Update admin_table Set [Password]  = 'admin1' WHERE [Password] = 'admin'





其次,上面的查询有点奇怪...只要找到'admin',就会将密码更新为'admin1'。您应该添加一些标准来标识要更新的记录,例如:



Second of all, above query is bit strange... It updates Password to 'admin1' whenever it find 'admin'. You should add some criteria to identify records you want to update, for example:

Update admin_table Set [Password]  = 'admin1' WHERE PK = 1



其中 PK - 表示表的私钥(唯一)。


where PK - means Private Key (unique) of table.


这篇关于MS-Access中的查询无法通过c#工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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