DbDataAdapter.FillSchema Method (DataTable, SchemaType, IDbCommand, CommandBehavior)
Assembly: System.Data (in system.data.dll)
'Declaration Protected Overridable Function FillSchema ( _ dataTable As DataTable, _ schemaType As SchemaType, _ command As IDbCommand, _ behavior As CommandBehavior _ ) As DataTable 'Usage Dim dataTable As DataTable Dim schemaType As SchemaType Dim command As IDbCommand Dim behavior As CommandBehavior Dim returnValue As DataTable returnValue = Me.FillSchema(dataTable, schemaType, command, behavior)
protected DataTable FillSchema ( DataTable dataTable, SchemaType schemaType, IDbCommand command, CommandBehavior behavior )
protected function FillSchema ( dataTable : DataTable, schemaType : SchemaType, command : IDbCommand, behavior : CommandBehavior ) : DataTable
The DataTable to be filled with the schema from the data source.
One of the SchemaType values.
The SQL SELECT statement used to retrieve rows from the data source.
One of the CommandBehavior values.
Return ValueA of DataTable object that contains 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 one or more primary key columns are returned by the SelectCommand, they are used as the primary key columns for the DataTable.
If no primary key columns are returned but unique columns are, the unique columns are used as the primary key if, and only if, all the unique columns are nonnullable. 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 preceding rules, but other constraint types are not added.
If the IDataAdapter encounters duplicate columns while populating a DataTable, it generates names for the subsequent columns, using the pattern "columnname1", "columnname2", "columnname3", and so on. If the incoming data contains unnamed columns, they are placed 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 placed 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 using column and table names should ensure that conflicts with these naming patterns does not occur.
FillSchema does not return any rows. Use the Fill method to add rows to a DataTable.
When handling batch SQL statements that return multiple results, the implementation of FillSchema for the .NET Framework Data Provider for OLE DB retrieves schema information for only the first result. To retrieve schema information for multiple results, use Fill with the MissingSchemaAction set to AddWithKey.
When using FillSchema, the .NET Framework Data Provider for SQL Server appends a FOR BROWSE clause to the statement being executed. The user should be aware of potential side effects, such as interference with the use of SET FMTONLY ON statements. See SQL Server Books Online for more information.Notes to Implementers This implementation of the FillSchema method is protected and is designed for use by a .NET Framework data provider.
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.