10. Understanding ODBC Connectivity : ODBC Programming : Query Execution : SQLExecDirect()—Execute Queries Directly
 
Share this page                  
SQLExecDirect()—Execute Queries Directly
SQLExecDirect() is commonly used for executing queries. The following code snippet creates a table and inserts a row of data.
Example: SQLExecDirect() Function
/* Allocate a statement handle. */
SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt );
 
/* Execute a "create table" query. */
SQLExecDirect(hstmt, "create table cars( model varchar(20) )",
    SQL_NTS);
 
/* Insert one row of data. */
SQLExecDirect(hstmt, "insert into cars ( model ) values
    ( 'Hummer' )", SQL_NTS);