我需要用Recordset中的AddNew,Edit方法,按照帮助提供的例子去做,怎么也不行,谁能告诉我该怎么样做?

解决方案 »

  1.   

    dim conn as ADODB.Connection
    Set conn = New ADODB.Connection  dim rs as ADODB.Recordset
    set rs = New ADODB.RecordsetDim strSQL As String   strSQL = App.Path & "\A.mdb"
       strSQL = Replace(strSQL, "\\", "\")
       
       With conn
           If .State = 1 Then
              .Close
           End If
           .CursorLocation = adUseClient
           .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & strSQL
           .Open
       End With   With rs
           .Open "SELECT * FROM Table;", conn, adOpenStatic, adLockOptimistic
           .MoveFirst
           .MoveLast
       End With
      

  2.   

    这样打开的rs集就可以.addnew及.edit了。
      

  3.   

    rs.CursorLocation = adUseClient
    rs.CursorType = adOpenStatic
    rs.LockType = adLockOptimistic
    rs.Open "SELECT * FROM Table;", conn
    rs.ActiveConnection = false
      

  4.   

    问题是addnew怎么用?表中有ID,Name,Phone三个字段
        With rs
            .AddNew
            !name = strName
            !phone = strPhone
            .Update
            .Book = .LastModified
        End With
    这样怎么不行?
      

  5.   

    ? Recordset 有Edit吗?
      有的人别误导别人了,本来是个简单的问题。
      

  6.   

    With rs
            .AddNew        !name = strName
            !phone = strPhone
            .Update
            .Book = .LastModified
        End With
      

  7.   

    With rs
           '新增
            .AddNew  (DAO、ADO中的用法)
            '修改
            .edit    (DAO中的用法,ADO中不要)                   
            !name = strName
            !phone = strPhone
            .Update
            .Book = .LastModified
        End With
      

  8.   

    Run-time error '3265':
    Item not found in this collection.
      

  9.   

    直接
    With rs
            .AddNew
            !name = strName
            !phone = strPhone
            .Update
            .Book = .LastModified
        End With
    就可以了,还需要.edit干身们 
      

  10.   

    With Data1.Recordset
            .AddNew
            !name = strName
            !phone = strPhone
            .Update
            .Book = .LastModified
        End With
    其中Data1为Data控件。