QueryDef.Prepare Property
Access Developer Reference |
Note |
---|
ODBCDirect workspaces are not supported in Microsoft Office Access 2007. Use ADO if you want to access external data sources without using the Microsoft Access database engine. |
Sets or returns a value that indicates whether the query should be prepared on the server as a temporary stored procedure, using the ODBC SQLPrepare API function, prior to execution, or just executed using the ODBC SQLExecDirect API function (ODBCDirect workspaces only). Read/Write QueryDefStateEnum.
Syntax
expression.Prepare
expression A variable that represents a QueryDef object.
Remarks
You can use the Prepare property to either have the server create a temporary stored procedure from your query and then execute it, or just have the query executed directly. By default the Prepare property is set to dbQPrepare. However, you can set this property to dbQUnprepare to prohibit preparing of the query. In this case, the query is executed using the SQLExecDirect API.
Creating a stored procedure can slow down the initial operation, but increases performance of all subsequent references to the query. However, some queries cannot be executed in the form of stored procedures. In these cases, you must set the Prepare property to dbQUnprepare.
If Prepare is set to dbQPrepare, this can be overridden when the query is executed by setting the Execute method's options argument to dbExecDirect.
Note |
---|
The ODBC SQLPrepare API is called as soon as the DAO SQL property is set. Therefore, if you want to improve performance using the dbQUnprepare option, you must set the Prepare property before setting the SQL property. |
Example
This example uses the Prepare property to specify that a query should be executed directly rather than first creating a temporary stored procedure on the server.
Visual Basic for Applications |
---|
|