Search notes:

ADODB.Command: execute

command.execute executes the action (typically an SQL statement) for which its command object was parametrized.
cmd.execute(recordsAffected, parameters, options)
All three parameters of execute are optional.
execute() returns a recordSet object.
Apparently, by default, an execution is not performed within a transaction.

Basic sequence of steps to execute a command

The following steps are required to execute a command. The language in which those are written is Visual Basic for Applications:
dim conn  as adodb.connection
 
conn.open "provider=...;...;..."
   
dim cmd as new adodb.command
    
set cmd.activeConnection = conn
cmd.commandType          = adCmdText
cmd.commandText          = "update table set col_1 = :val_1, col_2 = :val_2 where col_3 = :val_3"

dim param as adodb.parameter

set param = cmd.createParameter(, adInteger, adParamInput    ): cmd.parameters.append param
set param = cmd.createParameter(, adDate   , adParamInput    ): cmd.parameters.append param
set param = cmd.createParameter(, adVarChar, adParamInput, 99): cmd.parameters.append param    
      
cmd.parameters(0) = 42
cmd.parameters(1) = no
cmd.parameters(2) ="hello world"

dim nofRowsUpdated as long

'   Finally.... the statement can be executed:
'
cmd.execute nofRowsUpdated

debug.print(nofRowsUpdated & " rows were updated")

See also

The ADODB command object.

Index