Share via


DAO Querydef: Action Queries and SQL Pass-Through Queries

OverviewHow Do IFAQSampleODBC Driver List

This article tells you where to find information about action queries and SQL pass-through queries.

For information about action queries, including a definition, see the following topics in DAO Help:

  • Action Query

  • Querying a Database with SQL in Code

For information about SQL pass-through queries, including a definition, see the following topics in DAO Help:

  • Using SQL PassThrough with DAO

  • QueryDef Object

Quick SQL Pass-Through Queries

The fastest way to work with ODBC data sources is via attached tables. See the article DAO External: Working with External Data Sources. For doing bulk operations, the best, and often fastest, approach is to use an SQL pass-through query. It’s possible to do a quick pass-through query using a recordset and without having to create a querydef, even a temporary one. This is also helpful if you’re converting existing code that uses the DB_SQLPASSTHROUGH option in many places.

DAO’s Connect property for databases normally doesn’t have a value for Microsoft Jet (.MDB) databases. But you can assign an ODBC connect string to the property and use the dbSQLPassthrough option in a recordset. This means you don’t have to open the ODBC data source directly to use SQL pass-through.

For example:

// pdb is a pointer to a CDaoDatabase object
// (an .MDB database)
// Set up the connect string
CString strConnect = "ODBC;DSN=ntstuff;UID=sa;PWD=Fred;APP=App Name;WSID=MyComputer;DATABASE=pubs;TABLE=dbo.authors;";
pdb->SetConnect( strConnect );
// Use SQL pass-through in a recordset
// Set up the SQL and open the recordset
CString strSQL = "whatever";
CDaoRecordset rs( pdb );
try
{
    rs.Open( dbOpenSnapshot, strSQL, dbSQLPassThrough );
    // ...
}
// ...

What do you want to know more about?

See Also   DAO: Where Is...,