Share via


CDatabase::ExecuteSQL

voidExecuteSQL(LPCSTRlpszSQL**);**
throw(CDBException);

Parameters

lpszSQL

Pointer to a null-terminated string containing a valid SQL command to execute. You can pass a CString.

Remarks

Call this member function when you need to execute an SQL command directly. Create the command as a null-terminated string. ExecuteSQL does not return data records. If you want to operate on records, use a recordset object instead.

Most of your commands for a data source are issued through recordset objects, which support commands for selecting data, inserting new records, deleting records, and editing records. However, not all ODBC functionality is directly supported by the database classes, so you may at times need to make a direct SQL call with ExecuteSQL.

Example

CString strCmd = "UPDATE Taxes SET Federal = 36%";

TRY
{
   m_dbCust.ExecuteSQL( strCmd );
}

CATCH(CDBException, e)
{
   // The error code is in e->m_nRetCode
}

END_CATCH

CDatabase OverviewClass MembersHierarchy Chart

See Also   CDatabase::SetLoginTimeout, CRecordset