PDA

Click to See Complete Forum and Search --> : AddNew Method


gxpark
Aug 1st, 2000, 07:16 PM
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!

gxpark
Aug 2nd, 2000, 10:55 AM
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!