ActiveReports 12
Add a Dataset
ActiveReports 12 > ActiveReports User Guide > How To > Page Report/RDL Report How To > Work with Data > Add a Dataset

In a Page report or an RDL report, once you connect your report to a data source, in order to get a list of fields to use in the report, you need to add a dataset. Use the following instructions to add a dataset to the report.

Note: The data set for a CSV data source is automatically created on adding the data source.

These steps assume that you have already added a Page Report/RDL Report template and connected it to a data source. See Adding an ActiveReport to a Project and Connect to a Data Source for further information.

  1. In the Report Explorer, right-click the data source node (DataSource1 by default) and select the Add Data Set option or select Data Set... from the Add button.
  2. In the DataSet Dialog that appears, select the General page and enter the name of the dataset. This name appears as a child node to the data source icon in the Report Explorer.
  3. On the Query page of this dialog, select a Command Type from the dropdown list. 

    • Text - Allows the user to enter a SQL query or XML path in the Query box. See Visual Query Designer for further information on how to create a query using the interactive query designer.
    • StoredProcedure - Allows the user to enter the name of the stored procedure in the Query box.
    • TableDirect - Allows the user to enter the name of the table in the Query box.
  4. Click the Validate DataSet icon at the top right hand corner above the Query box to validate the query.
  5. The fields are automatically added to the Fields page in the DataSet dialog. For XML data, manually enter fields on the Fields page using valid XPath expressions.
  6. You can also set parameters, filters, and data options on the other pages of the dialog.
  7. Click the OK button to close the dialog. Your data set and queried fields appear as nodes in the Report Explorer.
Note: In case you are using an XML or JSON data source provider, you have to provide an XML path or JSON path using XPath or JSONPath expressions on the Query page, and generate fields on the Fields page of the DataSet dialog. See the following examples for details.

Query and Field settings for XML Data

Connection String

Example of an xmldata connection string.
xmldata=<people>
  <person>
    <name>
      <given>John</given>
      <family>Doe</family>
    </name>
  </person>
  <person>
    <name>
      <given>Jane</given>
      <family>Smith</family>
    </name>
  </person>
</people>;

XMLPath on Query Page

An XMLPath expression returns a value from an XML data source when evaluated with the query. The XML path is represented by slash (/) and the brackets ([]) represent iteration over collection of elements.

For example: /people/person/name

You can also build the XMLPath using XML DataSet Query Builder. Click the Edit with XML Query Designer icon to open XML DataSet Query Builder dialog and then choose the XPath from the tree nodes.

Fields

Once the query is set, build the Fields collection with two fields that contain the following name and value pairs:
Name: given; Value: given
Name: family; Value: family

See Use Fields in Reports to understand fields further.

Query and Field settings for JSON Data

Connection String

Example of a JSON data connection string.
jsondoc=C:\Data\customers.json;schemadata={
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "address": {
      "type": "object",
      "properties": {
        "streetAddress": {
          "type": "string"
        },
        "city": {
          "type": "string"
        }
      },
      "required": [
        "streetAddress",
        "city"
      ]
    },
    "phoneNumber": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string"
          },
          "code": {
            "type": "integer"
          }
        },
        "required": [
          "location",
          "code"
        ]
      }
    }
  },
  "required": [
    "address",
    "phoneNumber"
  ]
}

JSONPath on Query Page

A JSONPath expression returns a value from a JSON data source when evaluated with the query. The JSON path is usually represented by dot (.) notation, with the root object as '$'. The brackets ([]) represent the array of elements.

For example: $.Customers[*]

For more information, please see http://goessner.net/articles/JsonPath/.
You can also build the JSONPath using JSON Query Builder, which can be accessed from Edit with JSON Query Designer icon . The JSON Query Builder displays the structure of the JSON data, obtained from the JSON schema. You can choose the JSONPath from the tree nodes.

Fields

Once the query is set, build the Fields collection with two fields that contain the following name and value pairs:
Name: CompanyName; Value: CompanyName
Name: ContactName; Value: ContactName

 

See Also

Concepts