CdbConnection::CreateQueryDef Method

Creates a new QueryDef object in the specified Connection object.

Syntax

CdbQueryDefCreateQueryDef(LPCTSTR pstrName=NULL,

LPCTSTR pstrSQL=NULL);

Parameters

Type Example Description
LPCTSTR pstrName =NULL Optional. A pointer to a string that uniquely names the new QueryDef.
LPCTSTR pstrSQL =NULL Optional. A pointer to a string that is an SQL statement defining the QueryDef. If you omit this argument, you can define the QueryDef by setting its SQL property before or after you append it to a collection.

Usage

#include <afxole.h>
#include <dbdao.h>

CdbQueryDef       qd;
CdbConnection   conn;
LPCTSTR          lpctsrSQL = 
   _T("SELECT SALARY FROM EMPLOYEES WHERE LASTNAME = 'SMITH'");
...
qd = conn.CreateQueryDef(_T("SALARYDEF"), lpctsrSQL);
conn.Execute(_T("SALARYDEF"), dbFailOnError);