OleDbDataReader.GetSchemaTable Method

Definition

Returns a DataTable that describes the column metadata of the OleDbDataReader.

public:
 override System::Data::DataTable ^ GetSchemaTable();
public:
 virtual System::Data::DataTable ^ GetSchemaTable();
public override System.Data.DataTable GetSchemaTable ();
public override System.Data.DataTable? GetSchemaTable ();
public System.Data.DataTable GetSchemaTable ();
override this.GetSchemaTable : unit -> System.Data.DataTable
abstract member GetSchemaTable : unit -> System.Data.DataTable
override this.GetSchemaTable : unit -> System.Data.DataTable
Public Overrides Function GetSchemaTable () As DataTable
Public Function GetSchemaTable () As DataTable

Returns

A DataTable that describes the column metadata.

Implements

Exceptions

Remarks

The GetSchemaTable method maps to the OLE DB IColumnsRowset::GetColumnsRowset method, and returns metadata about each column in the following order:

DataReader column OLE DB column ID Description
ColumnName DBCOLUMN_NAME The name of the column; this might not be unique. If this cannot be determined, a null value is returned. This name always reflects the most recent renaming of the column in the current view or command text.
ColumnOrdinal DBCOLUMN_NUMBER The zero-based ordinal of the column. This column cannot contain a null value.
ColumnSize DBCOLUMN_COLUMNSIZE The maximum possible length of a value in the column. For columns that use a fixed-length data type, this is the size of the data type.
NumericPrecision DBCOLUMN_PRECISION If DbType is a numeric data type, this is the maximum precision of the column. The precision of columns with a data type of DBTYPE_DECIMAL or DBTYPE_NUMERIC depends on the definition of the column. If DbType is not a numeric data type, this is a null value.
NumericScale DBCOLUMN_SCALE If DbType is DBTYPE_DECIMAL or DBTYPE_NUMERIC, this is the number of digits to the right of the decimal point. Otherwise, this is a null value.
DataType None Maps to the .NET Framework type of the column.
ProviderType DBCOLUMN_TYPE The indicator of the column's data type. If the data type of the column varies from row to row, this must be DBTYPE_VARIANT. This column cannot contain a null value.
IsLong DBCOLUMNFLAGS_ISLONG The provider sets DBCOLUMNFLAGS_ISLONG if the column contains a Binary Long Object (BLOB) that contains very long data. The definition of very long data is provider-specific. The setting of this flag corresponds to the value of the IS_LONG column in the PROVIDER_TYPES rowset for the data type.
AllowDBNull DBCOLUMNFLAGS_ISNULLABLE The provider sets DBCOLUMNFLAGS_ISNULLABLE if the consumer can set the column to a null value, or if the provider cannot determine whether the consumer can set the column to a null value. A column may contain null values, even if it cannot be set to a null value.
IsReadOnly DBCOLUMNFLAGS_WRITE true if the column cannot be modified; otherwise false. The column is assumed to be writable if the provider has set either the DBCOLUMNFLAGS_WRITE or DBCOLUMNFLAGS_WRITEUNKNOWN flag.
IsRowVersion DBCOLUMNFLAGS_ISROWID The provider sets DBCOLUMNFLAGS_ISROWID if the column contains a persistent row identifier that cannot be written to, and has no meaningful value except to identity the row.
IsUnique DBCOLUMN_ISUNIQUE VARIANT_TRUE: No two rows in the base table-the table returned in BaseTableName-can have the same value in this column. IsUnique is guaranteed to be VARIANT_TRUE if the column represents a key by itself or if there is a constraint of type UNIQUE that applies only to this column.

VARIANT_FALSE: The column can contain duplicate values in the base table. The default of this column is VARIANT_FALSE.
IsKey DBCOLUMN_KEYCOLUMN VARIANT_TRUE: The column is one of a set of columns in the rowset that, taken together, uniquely identify the row. The set of columns with IsKey set to VARIANT_TRUE must uniquely identify a row in the rowset. There is no requirement that this set of columns is a minimal set of columns. This set of columns may be generated from a base table primary key, a unique constraint or a unique index.

VARIANT_FALSE: The column is not required to uniquely identify the row.
IsAutoIncrement DBCOLUMN_ISAUTOINCREMENT VARIANT_TRUE: The column assigns values to new rows in fixed increments.

VARIANT_FALSE: The column does not assign values to new rows in fixed increments. The default of this column is VARIANT_FALSE.
BaseSchemaName DBCOLUMN_BASESCHEMANAME The name of the schema in the data store that contains the column. A null value if the base schema name cannot be determined. The default of this column is a null value.
BaseCatalogName DBCOLUMN_BASECATALOGNAME The name of the catalog in the data store that contains the column. A null value if the base catalog name cannot be determined. The default of this column is a null value.
BaseTableName DBCOLUMN_BASETABLENAME The name of the table or view in the data store that contains the column. A null value if the base table name cannot be determined. The default of this column is a null value.
BaseColumnName DBCOLUMN_BASECOLUMNNAME The name of the column in the data store. This might be different from the column name returned in the ColumnName column if an alias was used. A null value if the base column name cannot be determined or if the rowset column is derived, but not identical to, a column in the data store. The default of this column is a null value.

Note

To make sure that metadata columns return the correct information, you must call ExecuteReader with the behavior parameter set to KeyInfo. Otherwise, some of the columns in the schema table may return default, null, or incorrect data.

Applies to

See also