CDaoQueryDef::Create

virtual void Create( LPCTSTR lpszName = NULL, LPCTSTR lpszSQL = NULL );
throw( CDaoException, CMemoryException );

Parameters

lpszName

 The unique name of the query saved in the database. For details about the string, see the topic "CreateQueryDef Method" in DAO Help. If you accept the default value, an empty string, a temporary querydef is created. Such a query is not saved in the QueryDefs collection.

lpszSQL

The SQL string that defines the query. If you accept the default value of NULL, you must later call SetSQL to set the string. Until then, the query is undefined. You can, however, use the undefined query to open a recordset; see Remarks for details. The SQL statement must be defined before you can append the querydef to the QueryDefs collection.

Remarks

Call this member function to create a new saved query or a new temporary query. If you pass a name in lpszName, you can then call Append to save the querydef in the database’s QueryDefs collection. Otherwise, the object is a temporary querydef and is not saved. In either case, the querydef is in an open state, and you can either use it to create a CDaoRecordset object or call the querydef’s Execute member function.

If you do not supply an SQL statement in lpszSQL, you cannot run the query with Execute but you can use it to create a recordset. In that case, MFC uses the recordset’s default SQL statement.

For information about querydefs, see the article DAO Querydef in Visual C++ Programmer's Guide.

CDaoQueryDef OverviewClass MembersHierarchy Chart

See Also   CDaoQueryDef::Open, CDaoQueryDef::CDaoQueryDef, CDaoRecordset::GetSQL