Parameters for an SQL statement or stored procedure call.

Property of

Query, StoredProc

Also ADO components:

ADOQuery, ADOStoredProc, ADODataShape

 

Description

 

BDE Query and StoredProc objects..

 

The params property contains an associative array that contains parameter names and values, if any, for an SQL statement in a Query object or a stored procedure call in a StoredProc object.

For a Query object, assigning an SQL statement with parameters to the sql property automatically creates the corresponding elements in the params array. Parameters are indicated by colons. The values you want to substitute are then assigned to the array elements in one of two ways:

  1. Manually, before the query is activated or requeried with requery( ).

For a StoredProc object, the Borland Database Engine will try to get the names and types of any parameters needed by a stored procedure, once the procedure name is assigned to the procedureName property. This works to varying degrees for most SQL servers. If it succeeds, the params array is filled automatically with the corresponding Parameter objects. You must then assign the values you want to substitute to the value property of those objects.

For SQL servers that do not return the necessary stored procedure information, include the parameters, preceded with colons, in parentheses after the procedure name. The corresponding Parameter objects in the params array will be created for you; then you must assign the necessary type and value information.

 

The Params property is a hidden property of ADOQuery, ADOStoredProc, and ADODataShape classes. The recommended way to access ADOParameter objects is via the Parameters property instead. The Params property internally maps to the Parameters property.

 

ADO data objects...

 

NOTE: when using params with ADO objects it is important to use the .value property when setting parameter values.

For example in a form that has an ado object...

 

   this.COMPANIES1 = new ADOQUERY(this)

   with (this.COMPANIES1)

      beforeConnect = class::COMPANIES1_BEFORECONNECT

      left = 15.0

      top = 4.0

      databaseName = "SQLTEST"

      sql = "SELECT * FROM KathyTest.dbo.Companies where TYPE >= :TYPE1 and TYPE <= :TYPE2  ORDER BY NAME "

      active = true

   endwith

 function COMPANIES1_beforeConnect

   this.params["TYPE1"].value = "A"

   this.params["TYPE2"].value = "Z"

   return

 

Other ADOParameter properties may be accessed as well, for example:

? this.params["TYPE1"].length