Export (0) Print
Expand All

OpenSchema Method (ADO)

The OpenSchema method on a Connection object obtains database schema information from the provider.

recordset = connection.OpenSchema ( QueryType, Criteria, SchemaID )

Parameters

QueryType
This parameter specifies a SchemaEnum value that indicates the type of schema query to run.

The SchemaEnum values supported by the Microsoft® OLE DB Provider for AS/400 and VSAM can be one of the constants listed in the table following the Parameters section.

Criteria
This optional parameter specifies an array of query constraints for each QueryType option, as listed below.

The values supported by the OLE DB Provider for AS/400 and VSAM can be one of the constants listed in the table following the Parameters section. This value depends on the QueryType.

Note  The adSchemaindexes TYPE restriction is not supported by the OLE DB Provider for DB2.

Note  The adSchemaProcedures PROCEDURE_SCHEMA, and adSchemaProcedureParameters PROCEDURE_SCHEMA restrictions are not supported when connecting to DB/2 on OS/390 platforms.

SchemaID
This optional parameter specifies the GUID for a provider-schema schema query not defined by the OLE DB specification. This parameter is required if the QueryType parameter is set to adSchemaProviderSpecific; otherwise, it is not used. This parameter is not supported by the OLE DB Provider for AS/400 and VSAM.

Values for QueryType

EnumerationValueDescription
adSchemaColumns4This value indicates that the QueryType is requesting column information for tables on the server (not supported when connecting to mainframes).
adSchemaIndexes12This value indicates that the QueryType is requesting index information about the tables on the server (not supported when connecting to mainframes).
adSchemaTables20This value indicates that the QueryType is requesting information about the tables on the server.
adSchemaProviderTypes22This value indicates that the QueryType is requesting provider-type information.

The SchemaEnum values supported by the Microsoft OLE DB Provider for DB2 and the Microsoft ODBC Driver for DB2 can be one of the constants listed in the following table.

EnumerationValueDescription
adSchemaColumns4This value indicates that the QueryType is requesting column information for tables on the server (not supported when connecting to mainframes).
adSchemaIndexes12This value indicates that the QueryType is requesting index information about the tables on the server (not supported when connecting to mainframes).
adSchemaProcedures16This value indicates that the QueryType is requesting information about stored procedures on the server.
adSchemaTables20This value indicates that the QueryType is requesting information about the tables on the server.
adSchemaProviderTypes22This value indicates that the QueryType is requesting provider-type information.
adSchemaProcedureParameters26This value indicates that the QueryType is requesting information about parameters used by stored procedures on the server.
adSchemaPrimaryKeys28This value indicates that the QueryType is requesting information about the primary keys for tables on the server.

Values for Criteria

QueryType / Enumeration
adSchemaColumns
TABLE_CATALOG
TABLE_SCHEMA
TABLE_NAME
COLUMN_NAME
adSchemaIndexes
TABLE_CATALOG
TABLE_SCHEMA
INDEX_NAME
TYPE
TABLE_NAME
adSchemaTables
TABLE_CATALOG
TABLE_SCHEMA
TABLE_NAME
TABLE_TYPE
adSchemaProviderTypes
DATA_TYPE
BEST_MATCH

The values supported by the OLE DB Provider for DB2 and the ODBC Driver for DB2 can be one of the constants listed in the following table, depending on the QueryType.

QueryType / Enumeration
adSchemaColumns
TABLE_CATALOG
TABLE_SCHEMA
TABLE_NAME
COLUMN_NAME
adSchemaIndexes
TABLE_CATALOG
TABLE_SCHEMA
INDEX_NAME
TABLE_NAME
adSchemaPrimaryKeys
TABLE_CATALOG
TABLE_SCHEMA
TABLE_NAME
adSchemaProcedures
PROCEDURE_CATALOG
PROCEDURE_SCHEMA (see Notes)
PROCEDURE_NAME
PROCEDURE_TYPE
adSchemaProcedureParameters
PROCEDURE_CATALOG
PROCEDURE_SCHEMA (see Notes)
PROCEDURE_NAME
PROCEDURE_TYPE
adSchemaProviderTypes
DATA_TYPE
BEST_MATCH
adSchemaTables
TABLE_CATALOG
TABLE_SCHEMA
TABLE_NAME
TABLE_TYPE

Return Values

Returns a Recordset object that contains schema information requested.

Remarks

The OpenSchema method on a Connection object is used to return information about the data source, such as information about the tables on the server and the columns in the tables.

The Criteria argument is an array of values that can be used to limit the results of a schema query. Each schema query supports a different set of parameters. The actual schemas are defined by the OLE DB specification under the IDBSchemaRowset interface. The schema queries supported in ActiveX® Data Objects (ADO) version 1.5 and later by the OLE DB Provider for AS/400 and VSAM are listed above.

The OpenSchema method allows an application to pass at run time the target library of a Partitioned Data Set (PDS/PDSE), a dataset, or a member name as one of the Criteria array arguments to retrieve the schema.

Providers are not required to support all of the OLE DB standard schema QueryType values. Specifically, only adSchemaTables, adSchemaColumns, and adSchemaProviderTypes are required by the OLE DB specification. However, the provider is not required to support the Criteria constraints listed above for those schema queries. Support for other schema QueryType values is optional.

The schema information specified in OLE DB is based on the assumption that providers support the concepts of a catalog and a schema. The ANSI SQL 92 specification defines them as follows:

  • A catalog contains one or more schemas, but always contains a schema named INFORMATION_SCHEMA which contains the views and domains of the information schema. In Microsoft SQL Server™ and Microsoft Access terms, a catalog is a database; in ODBC 2.x terms, a catalog is a qualifier.
  • A schema is a collection of database objects that are owned or have been created by a particular user. In Microsoft SQL Server and ODBC 2.x terms, a schema is an owner; there is no equivalent to a schema in a Microsoft Access database.

Schema information in ADO and OLE DB is retrieved using predefined schema rowsets.

This section contains:

To download updated Host Integration Server 2004 Help from www.microsoft.com, go to http://go.microsoft.com/fwlink/?linkid=29507.

Copyright © 2004 Microsoft Corporation.
All rights reserved.
Show:
© 2014 Microsoft