rs.Open "select * from a where b = '" & c & "'", ns, adOpenStatic, adLockOptimistic
rs.Update ("d"), e

解决方案 »

  1.   

    rs.Open "select * from a where b = '" & c & "'", ns, adOpenStatic, adLockOptimistic
    rs("d")="ABC"
    rs.Update
    rs.close^_^
      

  2.   

    在对ACCESS操作中是可行,但改为SQL server以后就不行了,能有什么法子吗?
      

  3.   

    用这个吧:
    ns.execute "update a set d='abc' where b='" & c & "'"^_^
      

  4.   

    (^_^)
    最好还是直接提效conn.execute "update <tablename> set <fieldname> = <value> where <condition>"
      

  5.   

    明白,但这样改要改好多,能不能有什么方法让rs.Update ("d"), e有效啊??先谢谢了
      

  6.   

    明白,但这样改要改好多,能不能有什么方法让rs.Update ("d"), e有效啊??先谢谢了//我第一个回答不是有吗?^_^
      

  7.   

    Recordset.Update Fields, Values
    rs.update "d" , e
      

  8.   

    rs.AddNew(新增行)
    Or
    cnn.CursorLocation=adUseClient(按默认行)rs.Update ("d") , e
      

  9.   

    回复huangjianyou,flyingZFX
    在对ACCESS操作中是可行,但改为SQL server以后就不行了,能有什么法子吗?
    总是提示:更新的查询失败.没发现要更新的行
      

  10.   

    谢谢XunBaian!!!!原来在这cnn.CursorLocation=adUseClient(按默认行)
      

  11.   

    Private Sub Command1_Click()
            Dim Conn As New ADODB.Connection
            Dim Rs As New ADODB.Recordset
            
            Conn.ConnectionString = "Provider=SQLOLEDB;data source=tepc-sql;initial catalog=master;user id=designer;password=t1e9p6c4"
            Conn.CommandTimeout = 5
            Conn.Open
            
            Rs.Open "select * from table1", Conn, adOpenStatic, adLockOptimistic, adCmdText
            
            Rs.Update ("a"), "aaa"
            
            Rs.Close
            Set Rs = Nothing
            Conn.Close
            Set Conn = Nothing
            
            MsgBox "OK"
    End Sub
      

  12.   

    Private Sub Command1_Click()
            Dim Conn As New ADODB.Connection
            Dim Rs As New ADODB.Recordset
            
            Conn.ConnectionString = "Provider=SQLOLEDB;data source=tepc-sql;initial catalog=master;user id=designer;password=t1e9p6c4"
            Conn.CommandTimeout = 5
            Conn.Open
            rs.CursorLocation=adUseClient'(按默认行)加上这句后"更新的查询失败.没发现要更新的行 " 的提示才没了 
            Rs.Open "select * from table1", Conn, adOpenStatic, adLockOptimistic, adCmdText
            
            Rs.Update ("a"), "aaa"
            
            Rs.Close
            Set Rs = Nothing
            Conn.Close
            Set Conn = Nothing
            
            MsgBox "OK"
    End Sub
    '**************
    感谢flyingZFX,问题已解决,原因见上