Log In
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
 [Expand]Product Information
 [Collapse]Creating Reports in Visual Studio
  [Expand]Adding a Report to Your .NET Application
  [Expand]Getting Started with DevExpress Reporting
  [Collapse]Detailed Guide to DevExpress Reporting
   [Expand]Storing and Distributing Reports
   [Collapse]Providing Data to Reports
    [Expand]Data Binding Overview
    [Collapse]Tutorials and Code Examples
      Bind a Report to a Database
      Bind a Report to a Stored Procedure
      Bind a Report to an MDB Database (Runtime Sample)
      Bind a Report to a Microsoft SQL Server Database (Runtime Sample)
      Register a Custom Schema Provider for a Synonym Database
      Bind a Report to an Object Data Source
      Bind a Report to a Collection that Implements the ITypedList Interface (Runtime Sample)
      Bind a Report to an Array List (Runtime Sample)
      Bind a Report to a List Object at Design Time and Provide Data at Runtime
      Bind a Report to an Entity Framework Data Source
      Bind a Report to an Entity Framework Stored Procedure
      Filtering an Entity Framework Data Source
      Bind a Report to a CSV File
      Bind a Report to a CSV File (Runtime Sample)
      Bind a Report to an Excel Workbook
      Bind a Report to an Excel Workbook (Runtime Sample)
      Bind a Report to an XML File
      Bind a Report to an XML File (Runtime Sample)
      Bind a Report to a Data Source Schema
      Bind a Report to Multiple Data Sources
      Bind a Report to Multiple Data Tables
   [Expand]Shaping Report Data
   [Expand]Report Navigation, Interactivity and Appearance
   [Expand]Reporting API
  [Expand]Detailed Guide to Visual Studio Report Designer
 [Expand]Creating End-User Reporting Applications
 [Expand]API Reference
[Expand]Report Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Bind a Report to a Data Source Schema

This tutorial demonstrates how to bind a report to a data source schema and supply data at runtime. This approach is useful when the report's data source is not available at design time.

To bind a report to a data source schema, do the following.

Expanded Create a Data Source Schema

You can create an XSD file containing a schema of a data source, using the WriteXmlSchema method. For example:

The created XSD file now may be used as a data source schema for new reports. For example, if a data source contains the Products table from the sample Northwind database (nwind.mdb file, which is shipped with XtraReports installation), the XML schema will look as follows:

<?xml version="1.0" standalone="yes"?>
<xs:schema id="nwindDataSet" targetNamespace="http://tempuri.org/nwindDataSet.xsd"
xmlns:mstns="http://tempuri.org/nwindDataSet.xsd" xmlns="http://tempuri.org/nwindDataSet.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:element name="nwindDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Products">
              <xs:element name="ProductID" msdata:AutoIncrement="true" type="xs:int" />
              <xs:element name="ProductName" minOccurs="0">
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="40" />
              <xs:element name="SupplierID" type="xs:int" minOccurs="0" />
              <xs:element name="CategoryID" type="xs:int" minOccurs="0" />
              <xs:element name="QuantityPerUnit" minOccurs="0">
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="20" />
              <xs:element name="UnitPrice" type="xs:decimal" minOccurs="0" />
              <xs:element name="UnitsInStock" type="xs:short" minOccurs="0" />
              <xs:element name="UnitsOnOrder" type="xs:short" minOccurs="0" />
              <xs:element name="ReorderLevel" type="xs:short" minOccurs="0" />
              <xs:element name="Discontinued" type="xs:boolean" minOccurs="0" />
              <xs:element name="EAN13" minOccurs="0">
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="12" />
    <xs:unique name="Constraint1" msdata:PrimaryKey="true">
      <xs:selector xpath=".//mstns:Products" />
      <xs:field xpath="mstns:ProductID" />

Expanded Assign the Data Source Schema to a Report

  1. Start Microsoft Visual Studio 2010, 2012, 2013, 2015 or 2017 and create a new application under any of the supported platforms, or open an existing one.

  2. Add a new blank report to it.

  3. Click the report's smart tag. In the invoked actions list, expand the drop-down menu for the DataSource property and click Add Report Data Source...

  4. On the first page of the invoked Data Source Wizard, select Database and click Next.

  5. The next page allows you to specify whether you want to use an existing data connection or create a new data connection. Select "No, I'd like to specify the connection parameters myself" and click Next.

  6. On the next page, specify the data provider (XML file) and the path to the database schema file.

    To proceed to the next wizard page, click Next.

  7. Click Next on the following page to save the created connection string to the configuration file.

  8. On the next page, you can select a table, view or stored procedure or construct a custom query using the Query Builder.


    Some of the data shaping capabilities available to SQL data sources (such as sorting, grouping and filtering data, as well as using aggregate functions) are not supported for XML files.

    Click Finish in the Data Source Wizard to exit the wizard.

    The newly created SQL data source will be displayed in the Components node of the Report Explorer.

    You can see the data source structure in the Field List window.

    Drop the required fields onto the report's Detail band from the Field List, to create report controls bound to these fields.

Expanded Obtain the Data and View the Result

At runtime create (or get) an instance of the data source of the same type which was used in the data source schema at design time.

The report (along with its controls) is now bound to data. Run the print preview form, and view the result.

Expanded See Also

How would you rate this topic?​​​​​​​