Help Center

CODBCStmt.ExecDirectmethod

Executes a preparable statement.

DatabasesmethodCODBCStmt.incdocumented

Syntax

FUNCTION ExecDirect (BYREF wszSqlStr AS WSTRING) AS SQLRETURN

Parameters

NameDescription
wszSqlStrSQL statement to be executed.

Return value

SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NEED_DATA, SQL_STILL_EXECUTING, SQL_ERROR, SQL_NO_DATA, or SQL_INVALID_HANDLE.

Description

Executes a preparable statement, using the current values of the parameter marker variables if any parameters exist in the statement. ExecDirect is the fastest way to submit an SQL statement for one-time execution.

Example

#include once "AfxNova/COdbc.inc" USING AfxNova

' // Connect with the database DIM wszConStr AS WSTRING * 260 = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=biblio.mdb" DIM pDbc AS CODBC = wszConStr

' // Allocate an statement object DIM pStmt AS COdbcStmt = @pDbc IF pStmt.Handle = NULL THEN PRINT "Failed to allocate the statement handle": SLEEP : END

' // Insert a new record pStmt.ExecDirect ("INSERT INTO Authors (Au_ID, Author, [Year Born]) VALUES ('999', 'José Roca', 1950)") IF pStmt.Error = FALSE THEN PRINT "Record added" ELSE PRINT pStmt.GetErrorInfo

Reference

  • Include file CODBCStmt.inc
  • Defined in AfxNova/COdbcStmt.inc:102
  • Documented in Databases/ODBC Classes/CODBCStmt Class.md
  • Topic: CODBCStmt Class