Content.AddQuery Method

Note

The Content object is included in Commerce Server 3.0 only for backward compatibility with sites created in Commerce Server 2.0. New sites should be constructed using ADOs. Connection strings (not DSNs) should be stored in the ConnectionStringMap (part of the site dictionary) and queries should be stored in the QueryMap Dictionary object.

The AddQuery method adds a query variable to the Content object.

Syntax

Content.AddQuery(QueryName, QueryText, Timeout, CommandType, MaximumRows, CursorType, CursorSize, RetrievalMethod)

Parameters

QueryName
A string variable that identifies the query. This name must be a non-Null string, but can contain spaces, numbers, and other non-Null characters.
QueryText
The SQL text of the query.
Timeout
Optional. A number that specifies the period of time, in seconds, to wait for the database to respond after an operation has been executed. A value of zero (0) indicates that the defaults for the database driver should be used. This value should be increased for database operations that are slow, or during operations that are known to take more time than is allowed by the default.
CommandType
Optional. An integer constant that specifies the kind of command that QueryText represents. Specifying the precise type of the command (as opposed to adCmdUnknown), results in faster execution time. The following table lists the possible constant values.
Constant Value Description
adCmdText 1 Evaluates QueryText as a textual definition of a command.
AdCmdTable 2 Evaluates QueryText as a table name.
AdCmdStoredProc 4 Evaluates QueryText as a stored procedure.
AdCmdUnknown 8 Type of command for the QueryText value is not known. This is the default value.

MaximumRows
Optional. The maximum number of rows to return. The default value is zero (0). Specifying a value greater than zero for queries that always return a small number of rows can substantially reduce the speed of query execution.
CursorType
Optional. An integer constant that references the ADO cursor type. The CursorType is used most often in conjunction with the CursorSize parameter. This parameter can contain one of the following values.
Constant Value Description
adOpenForwardReadOnly 0 Forward-only cursor. Identical to a static cursor except that you can only scroll forward through records. This improves performance in situations when you only need to make a single pass through a Recordset. (Default.)
adOpenKeyset 1 Keyset cursor. Like a dynamic cursor, except that you cannot view records that other users add, although records that other users delete are inaccessible from your Recordset. Data changes by other users are still visible.
adOpenDynamic 2 Dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the Recordset are allowed, except for bookmarks if the provider does not support them.
adOpenStatic 3 Static cursor. A static copy of a set of records that you can use to find data or generate reports. Additions, changes, or deletions by other users are not visible.

CursorSize
Optional. A number that specifies the number of rows to gather at one time. Specifying a value of one (1) optimizes the server-side cursor by ensuring that the server never has to retrieve more than a single row in server memory at a time. The default value is zero (0).
RetrievalMethod
Optional. A number that specifies the method to use to retrieve data from the results set. The default value is 2 (unknown). If you are using an Oracle database, the block retrieval method is unavailable; you must use the row retrieval option.

The following values can be used for this parameter.
Value Description
0 Block retrieval. Indicates that the result set contains no long text or binary data, or that the database fully supports block retrieval of long data.
1 Row retrieval. Indicates that the database supports the retrieval of long data, but only on a row-by-row basis.
2 Unknown. When you use this value, you effectively ask the system to determine for itself which method to call by searching for columns that contain binary data.

Remarks

When you execute a query using the Datasource object’s Execute method, you can simply pass Execute the name you have associated with the query through a call to AddQuery.

Although you can also pass the Execute method the SQL text of a query that you have not added to the Content object, this results in a degradation in performance time. For optimal efficiency, you should always pass Execute query variables stored by AddQuery in the Content object’s query list.

Additionally, if you pass Execute the text of your query, the Datasource object internally uses a set of default values for the Timeout, CommandType, MaximumRows, CursorType, and CursorSize values described previously, and you cannot override these defaults.

Related Topics


© 1997-1998 Microsoft Corporation. All rights reserved.