查询语句错误!

feiyusd 2003-04-08 08:38:48
我用ADO实现对Access数据库的操作,其中select 、delete 语句都能通过,但update 、insert语句却一直出错,请各位前辈帮忙!
表名:users 字段名(均为字符型) UserName、 PassWord 、DepartMent
其中UserName是关键列

update 语句
UPDATE Users Set PassWord='12' where UserName='xxx'
insert 语句
INSERT INTO Users (PassWord,UserName,DepartMent

错误提示是
实时错误 '-2147217900 (80040e14)'
Syntax error in UPDATE statement.
...全文
40 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
sxs69 2003-04-08
  • 打赏
  • 举报
回复
代码再详细一点
feiyusd 2003-04-08
  • 打赏
  • 举报
回复
不是空值!
jeansure 2003-04-08
  • 打赏
  • 举报
回复
那就是在数据库中你的password现在可能是MULL值,所以无法改,你将password的默认值加上('')试试
feiyusd 2003-04-08
  • 打赏
  • 举报
回复
什么密码?我的数据库密码为空,在表中密码字段为文本型,数据库是Access 2000下的。
jeansure 2003-04-08
  • 打赏
  • 举报
回复
如果是数字型的,不要加''号
jeansure 2003-04-08
  • 打赏
  • 举报
回复
你的密码是不是字符型的?
feiyusd 2003-04-08
  • 打赏
  • 举报
回复
试过了,错误依旧!
龙华 2003-04-08
  • 打赏
  • 举报
回复
第一句:
update [users] set......
第二句:
insert into [users] (password,username,......) values(a,b,c......)
antshome 2003-04-08
  • 打赏
  • 举报
回复
UPDATE [Users] Set PassWord='12' where UserName='xxx'

试试用方括号把表名括起来
饮水需思源 2003-04-08
  • 打赏
  • 举报
回复
Dim theConn As ADODB.Connection
Dim theConnString As String
Dim SQLStr AS String
theConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=F:\Guanli\SInfo.mdb;Persist Security Info=True"
theConn.Open theConnString
SQLStr = "UPDATE Users Set PassWord='12' where UserName='xxx'"
theconn.execute sqlstr

DaiLM 2003-04-08
  • 打赏
  • 举报
回复
Dim theConn As ADODB.Connection
Dim theConnString As String
Dim SQLStr As String
theConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=F:\Guanli\SInfo.mdb;Persist Security Info=True"
theConn.Open theConnString
SQLStr = "UPDATE Users Set PassWord='12' where UserName='xxx'"

Dim theComm As ADODB.Command
Set theComm.ActiveConnection = theConn
theComm.CommandText = SQLStr
theComm.Execute

Set theComm = Nothing
Set theConn = Nothing
feiyusd 2003-04-08
  • 打赏
  • 举报
回复
相关代码如下:

Dim theConn As ADODB.Connection
Dim theConnString As String
Dim SQLStr AS String
theConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=F:\Guanli\SInfo.mdb;Persist Security Info=True"
theConn.Open theConnString
SQLStr = "UPDATE Users Set PassWord='12' where UserName='xxx'"
RS.Open SQLStr, theConn, adOpenDynamic, adLockBatchOptimistic, 0

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧