例:
我写了个语句对Access数据库中表UserInfo数据进行更新Update UserInfo Set UserID='13',UserName='13',Password='13',UserType=1 where UserID='12'该语句在数据库本身的查询中可以正确执行
但是在VB代码里用Recordset对象的Open方法却提示Update语句错误为什么??

解决方案 »

  1.   

    Update没有返回结果集所以好象不能用Open
    用Execute
      

  2.   

    不是
    用的是ADODB.Recordset对象
    strsql="Update UserInfo Set UserID='13',UserName='13',Password='13',UserType=1 where UserID='12'"
    rs.open strsql,pubdbconn,adopenkeyset,adlockoptimistic
      

  3.   

    conn.execute "Update UserInfo Set UserID='13',UserName='13',Password='13',UserType=1 where UserID='12'"
      

  4.   

    conn.execute strsql,sum
    sum用来返回执行的记录数,如果为0则未进行更新,否则更新成功
      

  5.   

    用连接对象的Execute 方法来执行,因为update不返回记录集,如果返回记录集就用记录集对象的open方法。Conn.Execute "Update UserInfo Set UserID='13',UserName='13',Password='13',UserType=1 where UserID='12'"
      

  6.   

    conn.execute也试过了
    提示Update语句有错误该错误会是什么原因造成的?是不是跟表结构的设计有关呢?
      

  7.   

    谢谢大家的关注
    我发现了问题的所在,表结构设计中有一个字段名称为Password,我把它改称其它名字就可以了
    但是我不知道为什么会这样?