Results 1 to 2 of 2

Thread: AddNew Method

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242

    Angry

    Here I am again...

    I'm using ADO 2.5 with VB6, and after I succesfully open a database and fill a collection with a table recordsets, it appears I can't add new recordsets...

    I open it like this (snippet from a function I wrote):

    mdbConn.Mode = adModeReadWrite Or adModeShareDenyNone
    mdbConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    Filename & ";User ID=" & UserName & ";Password=" & Password & ";"

    If mdbConn.State <> adStateOpen Then
    OpenDatabase = Not OpenDatabaseResult.Success
    Exit Function
    End If

    Set mdbRS = mdbConn.Execute("SELECT * FROM Employees")

    ... then some code to store the records on a collection of custom class modules...

    and then, when I add a new item to the collection, the collection is supposed to add it automatically to the database, but when I issue the AddNew method (from the collection class module), I get the following error:

    Run-time error '3251'

    The object or provider can't execute the requested action.

    I translated the message from spanish, so it may actually be slightly different.

    What I'm doing wrong?

    thanks!

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242

    Red face Finally!

    Directly from MSDN:

    Execute Method (ADO Connection)

    "The returned Recordset object is always a read-only, forward-only cursor. If you need a Recordset object with more functionality, first create a Recordset object with the desired property settings, then use the Recordset object's Open method to execute the query and return the desired cursor type."

    So...thanks for reading me anyway!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width