我用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.

解决方案 »

  1.   

    UPDATE [Users] Set PassWord='12' where UserName='xxx'试试用方括号把表名括起来
      

  2.   

    第一句:
    update [users] set......
    第二句:
    insert into [users] (password,username,......) values(a,b,c......)
      

  3.   

    什么密码?我的数据库密码为空,在表中密码字段为文本型,数据库是Access 2000下的。
      

  4.   

    那就是在数据库中你的password现在可能是MULL值,所以无法改,你将password的默认值加上('')试试
      

  5.   

    相关代码如下: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
      

  6.   

    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.ExecuteSet theComm = Nothing
    Set theConn = Nothing
      

  7.   

    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