ADO Prepared Property

Definition and Usage

The Prepared property can return or set a boolean value. If set to True, it indicates that the command should save a prepared (or compiled) version of the query, which is specified in the CommandText property before the first execution of the Command object.

This will reduce the speed of the first execution of the command, but after the first execution, the provider will use the compiled version, which can speed up the execution.

If this property is False, the provider will directly execute the Command object without creating a compiled version.

If the provider does not support command preparation, once this property is set to True, the provider may return an error. If it does not return an error, it will simply ignore the request for the preparation command and set the Prepared property to False.

Syntax

objcommand.Prepared=true or false

Example

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set comm=Server.CreateObject("ADODB.Command")
comm.ActiveConnection=conn
comm.CommandText="orders"
comm.Prepared=true
response.write(comm.Prepared)
conn.close
%>