为用户提供一个更改密码的窗口,用户名用COMBOX,在加载时直接把数据库中的用户名表查询到并填充到combox中,然后提供一个password文本控接收用户的密码设置,我这样写到:
private sub cmdok_click()
conn.open dbq '打开连接
rs.open "update username set password='"& password.text & " ' where username=' " & combox.text & " ',conn,1,1
msgbox "ok!"
set rs = nothing
conn.colse
end sub
我在查询分析器里写一样的语句能够更改,但到这里就是不行啊?不知怎么回啊,我看到rs.update这个是什么呢?谢了各位!

解决方案 »

  1.   

    rs.open "update username set password='"& password.text & " ' where username=' " & combox.text & " ',conn,1,3
      

  2.   

    变成conn,1,3也不行啊,还是不能更改啊,
    Private Sub passok1_Click()
    conn.Open dbq
    rs.Open "Update username SET password = '" & passtxt.Text & " ' WHERE (username = ' " & name_com.Text & " ')", conn, 1, 3
    conn.Close
    passok1.Enabled = False
    MsgBox "用户名或密码更改成功!", , "提示"
    End Sub
    什么提示也没有啊,就是不能更改密码!
      

  3.   

    rs.open "update username set password='"& password.text & "' where username='" & combox.text & "',conn,1,1你的password='等的单引号后面多了个空格,去掉就是了。
      

  4.   

    你试试
    conn.execute "Update username SET password = '" & passtxt.Text & " ' WHERE (username = ' " & name_com.Text & " ')"
      

  5.   

    用楼上的方法:
    conn.execute "update....."
      

  6.   

    把sql语句赋给一个字符串变量,然后执行用conn.execute ,就可以了,
      

  7.   

    strsql="Update username SET password = '" & passtxt.Text & " '  WHERE (username = ' " & name_com.Text & " ')"
    conn.execute strsql
      

  8.   

    private sub cmdok_click()
    conn.open dbq '打开连接
    conn.execute "update username set password='" & password.text & "' where username='" & combox.text & "'"msgbox "ok!"conn.colse
    end sub
      

  9.   

    private sub cmdok_click()
    conn.open dbq '打开连接
    conn.execute "update username set password='" & password.text & "' where username='" & combox.text & "'"msgbox "ok!"conn.colse
    end sub就是这样写  不用罗嗦那么麻烦 少了一个  "'"  这么简单的事情还争论什么?
      

  10.   

    rs.open "update username set password='"& password.text & "' where username='" & combox.text & "',conn,2,3
    这样再试试看