Skip to main content

SqlDataSource.Fill(IEnumerable<IParameter>, String[]) Method

Validates and executes the specified queries with the required parameters.

Namespace: DevExpress.DataAccess.Sql

Assembly: DevExpress.DataAccess.v24.1.dll

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

Declaration

public void Fill(
    IEnumerable<IParameter> sourceParameters,
    string[] queriesToFill
)

Parameters

Name Type Description
sourceParameters IEnumerable<IParameter>

A collection of objects implementing the IParameter interface.

queriesToFill String[]

An array of String values, specifying the queries to fill.

Remarks

DevExpress Reporting

You can pass report parameters to the Fill method, as the following code snippet demonstrates:

using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
// ...
var report = new XtraReport1();

SqlDataSource ds = new SqlDataSource();

ds.ConnectionName = "connection1";
ds.ConnectionParameters = new MsSqlConnectionParameters(".", "NORTHWND", "sa", "dx", MsSqlAuthorizationType.SqlServer);
DevExpress.DataAccess.Sql.StoredProcQuery spQuery = new StoredProcQuery("SalesByCategory", "SalesByCategory");

spQuery.Parameters.Add(new QueryParameter("@CategoryName", typeof(DevExpress.DataAccess.Expression), new DevExpress.DataAccess.Expression("?p1", typeof(string))));
spQuery.Parameters.Add(new QueryParameter("@OrdYear", typeof(string), "2000"));

ds.Queries.Add(spQuery);

DevExpress.XtraReports.Parameters.Parameter p1 = new DevExpress.XtraReports.Parameters.Parameter();
p1.Name = "p1";
p1.Type = typeof(string);
p1.Value = "Seafood";
report.Parameters.Add(p1);

report.DataSource = ds;
report.DataMember = "SalesByCategory";

ds.Fill(new DevExpress.XtraReports.Parameters.Parameter[] { p1 }); 

Method Execution Workflow

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 a AggregateException. Use its InnerExceptions property to access a collection of QueryExecutionException objects (use their 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 a AggregateException. Use its InnerExceptions property to access a collection of QueryExecutionException objects (use their 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.

See Also