<< Click to Display Table of Contents >> Navigation: ThinBASIC Modules > ADODB > ADODB Module Classes > ADODB_Connection > ADODB_Connection Methods > <ADODB_Connection>.ExecuteCmd |
Description
Executes the specified query, SQL statement, stored procedure, or provider-specific text.
Syntax
nRecordsEffected = <ADODB_Connection>.ExecuteCmd(sCommandText [, lOptions])
Returns
Number of records that the operation affected
Parameters
Name |
Type |
Optional |
Meaning |
sCommandText |
String |
No |
A String value that contains the SQL statement, stored procedure, a URL, or provider-specific text to execute. Optionally, table names can be used but only if the provider is SQL aware. For example if a table name of "Customers" is used, ADO will automatically prepend the standard SQL Select syntax to form and pass "SELECT * FROM Customers" as a Transact-SQL statement to the provider. |
lOptions |
Number |
Yes |
A value that indicates how the provider should evaluate the CommandText argument. Can be a bitmask of one or more CommandTypeEnum or ExecuteOptionEnum values.
If lOptions is not specified, %adExecuteNoRecords will be used as default value |
Remarks
Using the ExecuteCmd method on a ADODB_Connection object executes whatever query you pass to the method in the CommandText argument on the specified connection.
Restrictions
See also
Examples
Uses "Console"
Uses "ADODB"
'---Declare a new pConnection variable and instantiate it in one line
Dim pConn As New ADODB_CONNECTION
pConn.Provider = "Microsoft.Jet.OLEDB.4.0"
pConn.Open(APP_SourcePath & "Biblio.mdb")
PrintL pConn.Provider
Printl pConn.ConnectionString
If pConn.State = %ADSTATEOPEN Then
Dim sSql As String
dim nRec as Long
'---
sSql = "Update Authors set [Year Born] = 2017 Where Au_ID = 1"
PrintL "Query is:", sSql
nRec = pConn.ExecuteCmd(sSql)
printl "Records effected (valid only for update queries):", nRec
pConn.Close
end If
WaitKey