The Parameters collection, referenced by the Parameters property of the Application object, provides a collection of command line parameters passed to Stonefield Query. For example, if you call Stonefield Query with the following command:

C:\Program Files\Stonefield Query\SFQuery.exe
  "ini=C:\Application Data" user=etaylor password=diamond

the collection contains three items: one for the INI parameter, one for the USER parameter, and one for the PASSWORD parameter.

Items in the collection have two properties: Name and Value. Name contains the name of the parameter (the text before an = sign, such as "ini", "user", and "password" in the example above) and Value contains the value (the text following an = sign, such as "C:\Application Data," "etaylor," and "diamond" in the example).

To obtain the value of a parameter, you have two choices: use the Item method of the Parameters collection to obtain a reference to the desired parameter object and then use its Value property, or call the built-in GetParameterValue function. Here's an example:

* Get the parameter object and its Value property:

loParameter = SQApplication.Parameters.Item('dbpassword')
lcPassword = loParameter.Value

* Get the value directly.

lcPassword = GetParameterValue('dbpassword')

The Item method of the Parameters collection returns a null value and GetParameterValue returns an empty string if the parameter was not specified on the command line.

The Running Stonefield Query help topic provides information about the command line parameters Stonefield Query knows how to deal with. In addition, you can pass other parameters in the form name=value, where name is the "name" of the parameter and value is the value for the parameter. Stonefield Query ignores any parameters it doesn't recognize, but your scripts could go through the Parameters collection to look for any parameters it may want.

Here's an example that may be used in the OpenDataSource script for a database to expect the database password to be passed as a "dbpassword" command-line parameter (in a real-world case, the password should be passed as encrypted text and decrypted in the script rather than using plain text):

Visual FoxPro

lparameters toApplication as SQApplication, toDatabase as Database, ;
  tcDataSource
local loDataSource as ODBCDataSource, loParameter
loDataSource = toDatabase.DataSources.Item(tcDataSource)
loParameter = toApplication.Parameters.Item('dbpassword')
if vartype(loParameter) = 'O'
    loDataSource.Password = loParameter.Value
endif
loDataSource.Disconnect()
return loDataSource.Connect()

VBScript

function Main(Application, Database, DataSource)
dim DataSourceObject, Parameter
set DataSourceObject = Database.DataSources.Item(DataSource)
set Parameter = Application.Parameters.Item("dbpassword")
if not isnull(Parameter) then
    DataSourceObject.Password = Parameter.Value
end if
DataSourceObject.Disconnect()
Main = DataSourceObject.Connect()
end function

JavaScript

function Main(Application, Database, DataSource) {
var DataSourceObject = Database.DataSources.Item(DataSource) ;
var Parameter ;
Parameter = Application.Parameters.Item('dbpassword') ;
if (Parameter != null) {
  DataSourceObject.Password = Parameter.Value ;
}
DataSourceObject.Disconnect() ;
return DataSourceObject.Connect() ;
}

C#

public static bool northwind_OpenDataSource(SFQApplication sfqApplication, 
  Database database, string dataSource)
{	
  DataSource dataSourceObject = database.DataSources.Item(dataSource);
  Parameter parameter = sfqApplication.Parameters.Item("dbpassword");
  if (parameter != null) 
  {
    dataSourceObject.Password = parameter.Value.ToString();
  }
  dataSourceObject.Disconnect();
  return dataSourceObject.Connect();
}

VB.NET

public shared function northwind_OpenDataSource(sfqApplication as SFQApplication, _
  database as Database, dataSource as string) as Boolean
  Dim dataSourceObject as DataSource = database.DataSources.Item(dataSource)
  Dim parameter as Parameter = sfqApplication.Parameters.Item("dbpassword")
  if Not parameter is Nothing
    dataSourceObject.Password = parameter.Value.ToString()
  End If
  dataSourceObject.Disconnect()
  return dataSourceObject.Connect()
End Function

Properties
See Collections for a list of properties.

Methods
See Collections for a list of methods.

See also

Application Object | Collections | Running Stonefield Query