Skip to main content

SqlDataSource.Fill() Method

Validates and executes all valid queries available in the SqlDataSource.Queries collection.

Namespace: DevExpress.DataAccess.Sql

Assembly: DevExpress.DataAccess.v24.1.dll

NuGet Packages: DevExpress.DataAccess, DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap

Declaration

public void Fill()

Remarks

If errors occur during data connection, a DatabaseConnectionException is thrown.

All queries are validated one by one. When validation errors occur, they are collected and returned by throwing an AggregateException. Use its InnerExceptions property to access a collection of QueryExecutionException objects (use each object’s InnerException property to access an actual ValidationException).

If the validation succeeds, all queries are executed one by one. If any errors occur during the execution of each query, these errors are collected and returned by throwing an AggregateException. Use its InnerExceptions property to access a collection of QueryExecutionException objects (use each object’s InnerException property to access an actual DevExpress.DataAccess.Native.Sql.SqlExecutionException).

To validate and execute only specific queries, use a corresponding Fill method overload with the queriesToFill parameter.

Example

The following code sample creates a new SqlDataSource:

using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
using DevExpress.XtraReports.UI;
// ...
private static SqlDataSource CreateSQLDataSource()
{
    // Creates a data source. 
    SQLiteConnectionParameters connectionParameters = new SQLiteConnectionParameters("Data/nwind.db", "");
    SqlDataSource dataSource = new SqlDataSource(connectionParameters);

    // Creates a SELECT query.
    SelectQuery query = SelectQueryFluentBuilder
        .AddTable("Products")
        .SelectColumn("ProductName")
        .SelectColumn("UnitPrice")
        .Build("selectQuery");

    // Adds the query to the collection and returns the data source. 
    dataSource.Queries.Add(query);
    dataSource.Fill();
    return dataSource;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the Fill() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also