O'Reilly logo

ADO.NET in a Nutshell by Bill Hamilton, Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

GetSchemaTable

Synopsis


DataTable dt = DataReader.GetSchemaTable();

Returns a DataTable that contains metadata for the current query. This table contains one row for each column in the result set and several fields that describe details such as column names and data types. Table 21-2 lists all columns returned in the schema DataTable, in order.

Table 21-2. Schema columns

Column

Description

ColumnName

The name of the column. If the query renamed the column using the AS keyword, this is the new name.

ColumnOrdinal

The ordinal number of the column.

ColumnSize

The maximum allowed length of values in the column or the size of the data type for fixed-length data type.

NumericPrecision

The maximum precision (number of digits) of the column for a numeric data type or null for all other data types.

NumericScale

The maximum scale (number of digits to the right of the decimal point) of the column for a numeric data type, or null for all other data types.

IsUnique

Indicates whether or not column values can be duplicated.

IsKey

Indicates whether or not this column is part of the primary key for the table.

BaseCatalogName

The name of the database that contains this table, or null if it can’t be determined.

BaseColumnName

The name of the column in the data source. If the query renamed the column using the AS keyword, this is the original name.

BaseSchemaName

The name of the schema in the data source, or null if it can’t be determined.

BaseTableName

The name of the table ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required