无法使用 C# windows 应用程序在访问中触发更新和插入查询 [英] Unable to fire update and insert query in access using C# windows application

查看:36
本文介绍了无法使用 C# windows 应用程序在访问中触发更新和插入查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 MS Access 后端创建一个 Windows 应用程序,但我在插入和更新查询方面遇到了一些问题.

I am trying to create one windows application with MS Access backend but I am facing some problems for insert and update query.

select 语句对我来说工作正常,但插入和更新不起作用.消息是:update"和insert into"中的语法错误

The select statement works fine for me, but insert and update are not working. The message is: syntax error in "update" and " insert into "

下面是我连接access数据库的连接字符串

below is my connection string to connect access database

<add key="AppConnection" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=GNDb.mdb;
  Jet OLEDB:Database Password=@black123;" ></add>

以及我试图从前端触发到后端的查询

And Queries that I am trying to fire from front end to backend

插入:插入tblU(UserName, Password)值('ops1', 'ops')

更新:更新 tblU set Password='pqr5' where UserName='pqr'

这是我的表架构:

ID            - AutoNumber
UserName text - text
Password      - text

在前端,我使用 Oledb 连接和命令.我正在使用 2003 ms 访问 mdb 文件.我不知道这是哪种语法错误?请给我建议更正/答案

In Front end I use Oledb connection and command. I am using 2003 ms access mdb file. I do not know which kind of syntax error is this? Please suggest me the correction/Answer

推荐答案

密码是保留字,应该用方括号括起来.

Password is a reserved word and should be enclosed in square brackets.

insert into tblU(UserName, [Password]) values('ops1', 'ops')

JetACE

这篇关于无法使用 C# windows 应用程序在访问中触发更新和插入查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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