Export (0) Print
Expand All
4 out of 7 rated this helpful - Rate this topic

DbDataAdapter.FillSchema Method

Adds a DataTable to a DataSet and configures the schema to match that in the data source.

Overload List

Adds a DataTable named "Table" to the specified DataSet and configures the schema to match that in the data source based on the specified SchemaType.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Overrides Public Function FillSchema(DataSet, SchemaType) As DataTable() Implements IDataAdapter.FillSchema
[C#] public override DataTable[] FillSchema(DataSet, SchemaType);
[C++] public: DataTable* FillSchema(DataSet*, SchemaType) [];
[JScript] public override function FillSchema(DataSet, SchemaType) : DataTable[];

Configures the schema of the specified DataTable based on the specified SchemaType.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Function FillSchema(DataTable, SchemaType) As DataTable
[C#] public DataTable FillSchema(DataTable, SchemaType);
[C++] public: DataTable* FillSchema(DataTable*, SchemaType);
[JScript] public function FillSchema(DataTable, SchemaType) : DataTable;

Adds a DataTable to the specified DataSet and configures the schema to match that in the data source based upon the specified SchemaType and DataTable.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Function FillSchema(DataSet, SchemaType, String) As DataTable()
[C#] public DataTable[] FillSchema(DataSet, SchemaType, string);
[C++] public: DataTable* FillSchema(DataSet*, SchemaType, String*) [];
[JScript] public function FillSchema(DataSet, SchemaType, String) : DataTable[];

Configures the schema of the specified DataTable based on the specified SchemaType, command string, and CommandBehavior values.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Protected Overridable Function FillSchema(DataTable, SchemaType, IDbCommand, CommandBehavior) As DataTable
[C#] protected virtual DataTable FillSchema(DataTable, SchemaType, IDbCommand, CommandBehavior);
[C++] protected: virtual DataTable* FillSchema(DataTable*, SchemaType, IDbCommand*, CommandBehavior);
[JScript] protected function FillSchema(DataTable, SchemaType, IDbCommand, CommandBehavior) : DataTable;

Adds a DataTable to the specified DataSet and configures the schema to match that in the data source based on the specified SchemaType.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Protected Overridable Function FillSchema(DataSet, SchemaType, IDbCommand, String, CommandBehavior) As DataTable()
[C#] protected virtual DataTable[] FillSchema(DataSet, SchemaType, IDbCommand, string, CommandBehavior);
[C++] protected: virtual DataTable* FillSchema(DataSet*, SchemaType, IDbCommand*, String*, CommandBehavior) [];
[JScript] protected function FillSchema(DataSet, SchemaType, IDbCommand, String, CommandBehavior) : DataTable[];

Example

[Visual Basic, C#, C++] The following example uses the derived class, SqlDataAdapter, to fill a DataSet with the schema, an array of DataTable objects with data, and returns the SqlParameterCollection collection to an array of IDataParameter objects. This example assumes that you have created an SqlDataAdapter and a DataSet.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of FillSchema. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Shared Function GetCustomerData(dataSetName As String) As DataSet

  Dim ds As DataSet = New DataSet(dataSetName)

  Dim conn As SqlConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind")

  Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT CustomerID, CompanyName, ContactName FROM Customers", conn) 

  conn.Open()

  da.FillSchema(ds, SchemaType.Source, "Customers")

  da.Fill(ds)

  conn.Close()

  Return ds
End Function

[C#] 
public static DataSet GetCustomerData(string dataSetName)
{
  DataSet ds = new DataSet(dataSetName);

  SqlConnection conn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind");

  SqlDataAdapter da = new SqlDataAdapter("SELECT CustomerID, CompanyName, ContactName FROM Customers", conn); 

  conn.Open();

  da.FillSchema(ds, SchemaType.Source, "Customers");

  da.Fill(ds);

  conn.Close();

  return ds;
}

[C++] 
public:
  static DataSet* GetCustomerData(String* dataSetName)
  {
    DataSet* ds = new DataSet(dataSetName);

    SqlConnection* conn = new SqlConnection(S"Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind");

    SqlDataAdapter* da = new SqlDataAdapter(S"SELECT CustomerID, CompanyName, ContactName FROM Customers", conn); 

    conn->Open();

    da->FillSchema(ds, SchemaType::Source, S"Customers");

    da->Fill(ds);

    conn->Close();

    return ds;
  }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

DbDataAdapter Class | DbDataAdapter Members | System.Data.Common Namespace

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.