DbExecute - method of object PmAdo

Executes the command entered in the syntax of the SQL language.
DbExecute(sId As String, sCommand As String, sParams As String) As Object
Set oRecordset = oDb.DbExecute(sId, sCommand, sParams)
sId(String) Unique identifier that is used by the PmAdo object to store the result data in the form of AdoRecordset.

If an empty string ("") is used, then the SQL comman is executed and the data is returned as AdoRecordset, but the PmAdo object will not store it. This is handy if it is necessary to execute some SQL query in the script and process the resulting data immediately, and release the AdoRecordset object right after that.

If the command does not return any data, then the empty string is returned.
sCommand(String) Usualy, it is a SQL syntax command (INSERT, UPDATE, DELETE, etc.), that does not return any data in the form of AdoRecordset. It can also return the data as the AdoRecordset object containing SQL query SELECT, table name, calling the saved procedure, name or URL address of the file containing the saved AdoRecordset object.
sParams(String) Additional parameters of the DbExecute method. Entries are in format PmNamedValues, for example "command:text;execute:norecords;".
"command:xxx;" (optional) - Defines how the corresponding ADO Provider evaluates the sSource parameter, especially if it contains something different than SQL language syntax query/command (e.g. SELECT, INSERT, etc.).
text (default) - Indicates that the ADO Provider should evaluate the sSource parameter as a textual definition of a command. Corresponds to the ADO adCmdText value.
table - Indicates that the ADO Provider should generate an SQL query to return all records from the table named in the sSource parameter. Corresponds to the ADO adCmdTable value.
storedproc - Indicates that the ADO Provider should evaluate the sSource parameter as a stored procedure. Corresponds to the ADO adCmdStoredProc value.
file - Indicates that a persisted (saved) AdoRecordset object should be restored from the file named in the sSource parameter. Corresponds to the ADO adCmdFile value.
tabledirect - Indicates that the ADO Provider should return all records from the table named in the sSource parameter. Corresponds to the ADO adCmdTableDirect value.
unknown - Indicates that the type of command in the sSource parameter is not known. The ADO Provider will try to evaluate it, but it will just consume more time. Corresponds to the ADO adCmdUnknown value.
"execute:xxx;" (optional) - Instructs the corresponding ADO Provider how to execute the SQL query. The default mode is the synchronous query, i.e. the method waits for the operation result.
async - Asynchronous query, i.e. the method does not wait for the operation result. Corresponds to the ADO adAsyncExecute value.
asyncfetch - Indicates that the rows defined by the ADO Recordset.CacheSize property are to be read synchronously and any remaining records should be fetched asynchronously. Corresponds to the ADO adAsyncFetch value.
asyncfetchnonblocking - Defines that the main thread will never be blocked while reading is being processed. If the requested row is not read, the cursor will be moved to the end. Corresponds to the ADO adAsyncFetchNonBlocking value.
norecords - Defines that the called query/command does not return any data. If so, the data will be discarded and not returned (no AdoRecordset Nothing value). Corresponds to the ADO adExecuteNoRecords value.
record - specifies that the called query/command returns a single row, that has the form of AdoRecord object. Corresponds to the ADO adExecuteRecord value.
Return Values:
Returns the result data as AdoRecordset, if the command returns any data.
ADO Record object:

Depending on the specific ADO Provider it is possible, that a single row SQL query result will not be returned as AdoRecordset object containing a single record, but as a AdoRecord object, representing the single row. Není to ale typické pro nejběžněji užívané ADO Provider. The AdoRecord object is usually returned by explicit operations, when the specific AdoRecord is returned from the existing AdoRecordset object. The AdoRecord object consists of multiple AdoField objects, similar as the AdoRecordset object. The difference is that the methods for moving the position of current record are not supported (e.g. MoveFirst). In order to keep the documntation simple, it will be referred only to the commonly returned object AdoRecordset, although in some special cases the system may also return the AdoRecord object.

Adding new record into the table ("table1") in the PmAdo object ("/TestAdoDb").
Dim oDb
Set oDb = pMe.Pm("/TestAdoDb")
oDb.DbExecute "", "INSERT table1 (name, value) VALUES ('pi', 3.14)", ""
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice