Поделиться через


CDatabase::ExecuteSQL

Call this member function when you need to execute a SQL command directly.

void ExecuteSQL( 
   LPCTSTR lpszSQL  
);

Параметры

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

Заметки

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.

Пример

try
{
   m_dbCust.ExecuteSQL(
      _T("UPDATE Taxes ")
         _T("SET Rate = '36' ")
         _T("WHERE Name = 'Federal'"));
}
catch(CDBException* pe)
{
   // The error code is in pe->m_nRetCode
   pe->ReportError();
   pe->Delete();
}

Требования

Header: afxdb.h

См. также

Основные понятия

CDatabase Class

CDatabase Members

Hierarchy Chart

CDatabase::SetLoginTimeout

CRecordset Class