Adapter. Fill Schema(DataSet, SchemaType) Method
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public: cli::array <System::Data::DataTable ^> ^ FillSchema(System::Data::DataSet ^ dataSet, System::Data::SchemaType schemaType);
public System.Data.DataTable FillSchema (System.Data.DataSet dataSet, System.Data.SchemaType schemaType);
abstract member FillSchema : System.Data.DataSet * System.Data.SchemaType -> System.Data.DataTable
Public Function FillSchema (dataSet As DataSet, schemaType As SchemaType) As DataTable()
An array of DataTable objects that contain schema information returned from the data source.
The FillSchema method retrieves the schema from the data source using the SelectCommand. The connection object associated with the SelectCommand must be valid, but it does not need to be open. If the connection is closed before FillSchema is called, it is opened to retrieve data, then closed. If the connection is open before FillSchema is called, it remains open.
A FillSchema operation adds a DataTable to the destination DataSet. It then adds columns to the DataColumnCollection of the DataTable and configures the following DataColumn properties if they exist at the data source:
If no primary key columns are returned but unique columns are, the unique columns are used as the primary key if all the unique columns are non-nullable. If any of the columns are nullable, a UniqueConstraint is added to the ConstraintCollection, but the PrimaryKey property is not set.
If both primary key columns and unique columns are returned, the primary key columns are used as the primary key columns for the DataTable.
Note that primary keys and unique constraints are added to the ConstraintCollection according to the previous rules, but other constraint types are not added.
If a unique clustered index is defined on a column or columns in a SQL Server table and the primary key constraint is defined on a separate set of columns, then the names of the columns in the clustered index will be returned. To return the name or names of the primary key columns, use a query hint with the SELECT statement that specifies the name of the primary key index. For more information about how to specify query hints, see Hints (Transact-SQL) - Query.
If the IDataAdapter encounters duplicate columns while populating a DataTable, it generates names for the successive columns, using the pattern "columnname1", "columnname2", "columnname3", and so on. If the incoming data contains unnamed columns, they are put in the DataSet according to the pattern "Column1", "Column2", and so on. When multiple result sets are added to the DataSet, each result set is put in a separate table. Additional result sets are named by appending integral values to the specified table name (for example, "Table", "Table1", "Table2", and so on). Applications should use caution when using column and table names to ensure that conflicts with these naming patterns do not occur.