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

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); ...

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