ADO/COM optional argument success.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ADO/COM optional argument success.

Craig H. Anderson
Earlier I asked for help on how to use an ADO method
that had 2 optional arguments.  I finally had success
like this.  Optional arguments are given as (VARIANT unspecified).

dbc := (ADODB_Connection new)
 open: 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Data\NWIND.mdb;'
 userID: '' password: '' options: 0 .
xx := dbc openSchema: 20 restrictions: (VARIANT unspecified) schemaID:
(VARIANT unspecified).

 From the MSDN description.
Set recordset = connection.OpenSchema (QueryType, Criteria, SchemaID)
Parameters
QueryType   Any SchemaEnum value that represents the type of schema query to
run.
Criteria   Optional. An array of query constraints for each QueryType
option,
            as listed in SchemaEnum.
SchemaID   The GUID for a provider-schema query not defined
            by the OLE DB specification. This parameter is required if
QueryType
             is set to adSchemaProviderSpecific; otherwise, it is not used.


Reply | Threaded
Open this post in threaded view
|

Re: ADO/COM optional argument success.

Blair McGlashan
Craig

You wrote in message news:s7hI5.103498$[hidden email]...
> Earlier I asked for help on how to use an ADO method
> that had 2 optional arguments.  I finally had success
> like this.  Optional arguments are given as (VARIANT unspecified).
>...

Sorry, I didn't realise you were asking about optional arguments, or I
missed your posting, as otherwise I could have told you this straight away.

BTW: The reason that the type-library wizard doesn't generate methods
without the optional arguments (i.e. ones that would pass the optional
arguments for you) even though it knows when arguments are optional, is that
I was worried about combinatorial-explosion, i.e. a method with several
arguments, a few of which are optional, would potentially generate quite a
large number of combinations if one unthinkingly generates each possible
combination of mandatory and optional arguments. This is similar to a
typical Smalltalk problem that occurs most frequently in class side instance
creation methods when one can pass extra operands to override the defaults
in a new object, and in that case one swings between doing the lot or only a
minimal set.

I think perhaps it might be an idea to generate two methods in each case.
One with all optional arguments, and one with none. This will make it easier
for the programmer to intelligently add those extra which might be needed,
and handle the quite common case where the optional arguments are hardly
ever used.

Regards

Blair McGlashan
Object Arts Ltd
http://www.object-arts.com