Name

FillSchema

Synopsis


DataTable[] dta = DataAdapter.FillSchema(DataSet ds,

    SchemaType schemaType);

DataTable[] dta = DataAdapter.FillSchema(DataTable dt,

    SchemaType schemaType);

DataTable[] dta = DataAdapter.FillSchema(DataSet ds,

    SchemaType schemaType, String tableName);

Creates a schema in the DataSet based on the data source. The schema information retrieved is based on the query in the SelectCommand.

Parameters

dta

Returns an array of DataTable objects added to the DataSet.

ds

The DataSet in which to create the schema.

dt

The DataTable in which to create the schema.

schemaType

One of the SchemaType enumeration values described in Table 29-16, which specifies how table mappings are treated during the FillSchema operation.

Table 29-16. SchemaType enumeration

Value

Description

Mapped

Table mappings in the data adapter are applied to the incoming schema. This transformed schema is used.

Source

Ignores table mappings in the data adapter. The data source schema is used.

tableName

The name of the DataTable in which to create the schema.

Example

The following example demonstrates how to get the schema for both a table within a DataSet object and a DataTable object using the DataAdapter FillSchema( ) method:

// connection string and select statement String connString = "Data Source=(local);Integrated security=SSPI;" + "Initial Catalog=Northwind;"; String selectSql = "SELECT * FROM Orders"; // create the data adapter SqlDataAdapter da = new SqlDataAdapter(selectSql, connString); ...

Get ADO.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.