Runs an action query or executes an SQL statement on a specified Connection or Database object.
Syntax
VOIDExecute(LONG lOption=-1);
Parameters
| Type | Example | Description |
| LONG | lOption | Optional. A constant or combination of constants that determines the data integrity characteristics of the query, as specified in Settings. |
Settings
You can use the following constants for options.
| Constant | Description |
| dbDenyWrite | Denies write permission to other users (Microsoft Jet workspaces only). |
| dbInconsistent | (Default) Executes inconsistent updates (Microsoft Jet workspaces only). |
| dbConsistent | Executes consistent updates (Microsoft Jet workspaces only). |
| dbSQLPassThrough | Executes an SQL pass-through query. Setting this option passes the SQL statement to an ODBC database for processing (Microsoft Jet workspaces only). |
| dbFailOnError | Rolls back updates if an error occurs (Microsoft Jet workspaces only). |
| dbSeeChanges | Generates a run-time error if another user is changing data you are editing (Microsoft Jet workspaces only). |
| dbRunAsync | Executes the query asynchronously (ODBCDirect Connection and QueryDef objects only). |
| dbExecDirect | Executes the statement without first calling SQLPrepare ODBC API function (ODBCDirect Connection and QueryDef objects only). |
Note that the constants dbConsistent and dbInconsistent are mutually exclusive. You can use one or the other, but not both.
Usage
#include <afxole.h>
#include <dbdao.h>
CdbQueryDef qd;
CdbConnection conn;
LPCTSTR lpctsrSQL =
_T("SELECT SALARY FROM EMPLOYEES ")
_T("WHERE LASTNAME = 'SMITH'");
...
qd = conn.CreateQueryDef(_T("SALARYDEF"), lpctsrSQL);
qd.Execute(dbFailOnError);