Open ADODB.Recordset with Parameters

jal

Registered User.
Local time
Today, 14:40
Joined
Mar 30, 2007
Messages
1,709
After adding parameters to a Command object, I use this code:

Set RS = Cmd.Execute

Apparently, this returns a forward only recordset. In other words it doesn't seem to give me other options as to the type of recordset created.

Is there a way to set the type of recordset and still be able to use parameters?
 
Ok, got it.

Dim recSet As New ADODB.Recordset
recSet.CursorType = adOpenKeyset
recSet.LockType = adLockOptimistic
recSet.Open cmd
 
As a general FYI- ADO will fill in the blanks for you if you don't detail stuff. For instance if all you instantiated was a recordset object with a SQL statement and connection string, ADO will build a connection object, a command object and fill the properties of all three objects behind the scene. This gives you more flexibility compared to DAO where you had to explicitly instantiate a hierarchy of objects to get to the desired objects.

One way if you find yourself needing a different set of defaults is to write a generic procedure that fills in the desired objects and its properties that you find yourself using more often than ADO's supplied defaults and call it when you want a particular object.

HTH.
 

Users who are viewing this thread

Back
Top Bottom