Name
FillSchema
Synopsis
DataTable[]dta
= DataAdapter.FillSchema(DataSetds
, SchemaTypeschemaType
); DataTable[]dta
= DataAdapter.FillSchema(DataTabledt
, SchemaTypeschemaType
); DataTable[]dta
= DataAdapter.FillSchema(DataSetds
, SchemaTypeschemaType
, StringtableName
);
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 theDataSet
.-
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 theFillSchema
operation.
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.