# Data Sources

Data sources establish the connection between Exago and a database or a web service. Although typically only one database is used, Exago can join data from different sources into a single report.

> NOTE. To utilize some types of Data Sources you may need to download and install the appropriate driver. Please see Data Source Drivers for more information.

All existing Data Sources are listed in the Main Menu under 'Data'. All the Sources you are adding or editing will be displayed in a Tab titled Data Sources.

- To add a new Data Source click ‘Sources’ in the Main Menu then click the Add button.
- To edit a Data Source either double click it or select the Data Source and click the Edit button.
- To delete a Data Source select it and click the Delete button.
- To save changes click the Ok button or press the Apply button.

Each Data Source must have the following:

### Name

A name for the data source.

### Type

The type of source being used. Valid types include:

- mssql – Microsoft SQL Server.
- mysql – MySQL.
- oracle – Oracle.
- postgres – PostgreSQL.
- db2 – IBM db2.
- informix – IBM Informix.
- websvc – Web Service. For more information see Web Services.
- assembly - .NET Assembly dll. For more information see .NET Assemblies.
- file – XML or Excel file. For more information see Excel and XML Files.
- msolap – OLAP. For more information OLAP and MDX Queries.
- odbc – ODBC Driver. For more information see ODBC drivers.

### Schema/Owner Name (blank for default)

Provide a default database schema for the data source.

> NOTE. Only use this if you are using schema to provide Multi-Tenant security. For more details see Multi-Tenant Environment Integration.

### Connection String

The method that is used to connect to the data source. Connection strings vary by type:

- mssql, oracle, postgres, mysql and olap – Please refer to ConnectionStrings.com for database connection strings.
- websvc – Can take up to four parameters but only requires url.
  - url – The url of the web service.
  - Authentication (optional) – Set to ‘basic’ to utilize basic authentication through IIS. This will send the userid and password as clear text (unless https is used).
  - uid (optional) – User id is passed to the web service.
  - pwd (optional) – Password is passed to the web service
- assembly – Requires two parameters.
  - assembly – The full path of the assembly name.
  - class – The class name in the assembly where the static methods will be obtained.
- file – Requires the physical path to the excel or xml file and the file type. Ex. File=C:\example.xls;Type=excel;

Click the green check mark to verify the connection succeeds.

# Data Source Drivers

Below is a list and the associated links for recommended ADO.NET drivers for each type of Data Source.

- SQL Server - No external ADO.NET driver needed

- Oracle - ODAC1120320_x64 or newer – Oracle ODAC Connector - Link

- MySQL/MariaDB – dcmysqlfree.exe – Devart Connector - Link

- PostgreSQL – dcpostgresqlfree.exe – Devart Connector - Link

- DB2/Informix – 5.exe or newer – IBM Data Server Driver Package – Link

# Web Services and .NET Assemblies

Web Services and .NET Assemblies can be used as Data Sources. This is possible when the Web Service and .NET Assemblies underlying methods are setup as Data Objects.

An advantage of doing this is being able to use high-level language to manipulate the data being reported on at run-time. The main disadvantage is not being able to take advantage of the database to perform joins with other data objects; data from methods can still be joined, but the work to do this is done within Exago. For more information see Note about Cross Source Joins.

## Parameters

Parameters are passed from Exago to Web Services and .NET Assemblies. Three types of parameters can be passed but only Call Type is required.

### Call Type (required)

Integer that specifies what Exago needs at the time of the call. There are three possible values. You may specify the name of this parameter in the Programmable Object Settings of the General Section.

- 0 : Schema - returns a DataSet with no rows.
- 1 : Data - returns a full DataSet.
- 2 : Filter Dropdown Values – returns data for the filter dropdown list. The Data Field being requested is passed in the column parameter. The filter type is passed in the filter parameter (see below).

### Column, Filter and Sort Strings (optional)

To optimize performance Exago can pass user-specified sorts and filters to the Web Service or .NET Assembly. This process reduces the amount of data sent to Exago. If these parameters are not used, all of the data will be sent to Exago to sort and filter. Column, filter and sort strings are sent as standard SQL. You may specify the name of these parameters in the Programmable Object Settings of the General Section.

### Custom Parameter Values (optional)

Additional parameters can be specified to be sent to individual methods in the Data Object Menu.

> IMPORTANT. When a Web Service or .NET Assembly is first accessed it is compiled and kept in an internal cache within Exago. This is done in order to increase performance. Due to this internal cache, Exago will not be aware of any changes within the Web Service or .NET Assembly. If the service or assembly is subsequently changed; Exago will execute the prior compiled version. Thus, when you modify the Web Service or .NET Assembly reset the internal cache of Exago by clicking the green check mark of the Data Source () or by restarting IIS.

> NOTE. If an Exago .NET API application needs to access reports which use an Assembly data source, it must include a reference to the assembly WebReportsAsmi.dll.

### SessionInfo (optional) (v2016.2+)

Session state variables. See SessionInfo for more information.

## NET Assemblies

It is important to note that when a connection string for .NET Assembly is set the class name must match the name of the class where the static methods will be searched. UNC or absolute paths may be used. Make sure that the assembly has read privileges for the IIS user running Exago. Below is an example of a .NET Assembly connection string:

assembly=\\MyServerName\MyShareName\MyAssembly.dll;class=Main

.NET Assembly methods must be static. Below is an example of a .NET Assembly method.

    public class Main
    {
      public static DataSet dotnet_optionees(int callType, string columnStr, string filterStr, int myCustomParameter)
      {
        switch (callType)
        {
          case 0:
            // return schema
          case 1:
            // return data
          case 2:
            // return filter values for dropdown
        }
      }
    }

Method signature using SessionInfo (v2016.2+):

    public class Main
    {
      public static DataSet dotnet_optionees(WebReports.Api.Common.SessionInfo sessionInfo, int callType, string columnStr, string filterStr, int myCustomParameter)
      {
        switch (callType)
        ...
      }
    }

### Web Services

Web Services are accessed via SOAP. Below is an example of a Web Service connection string: url=http://MyServer/MyWebService.asmx

Web services methods are similar to .NET Assembly methods with the following exceptions:

- Methods do not need to be static
- Methods must return a serialized XML string. The returned XML must follow the structure used by the C# method DataSet.GetXML. An example of XML format can be found in the following section.

# Excel and XML Files

Exago can use Microsoft Excel and XML files as Data Sources. Remember though that Excel and XML files are not databases. Simply put, these Data Sources do not offer the speed, performance, security or heavy lifting of a real database. Using Excel and XML files is recommended only if your dataset is small or if the information is only available in this format.

### Connection string

File=C:\example.xls;Type=excel;

## Excel

Each worksheet in the Excel file will be read as a separate table. Each worksheet’s name will be read as the table’s title. The top row will be read as the column header, and the remaining cells will be read as the data. Do not leave any blank rows or columns.

## XML

The XML document must begin with the schema. After defining the schema the data must be placed into the appropriate tags. For reference see the working example below:

    <?xml version="1.0" encoding="UTF-8"?>
    <ExagoData>
       <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="ExagoData">
          <xs:element name="ExagoData" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
             <xs:complexType>
                <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="Call">
                      <xs:complexType>
                         <xs:sequence>
                            <xs:element name="CallID" type="xs:unsignedInt" minOccurs="0" />
                            <xs:element name="StaffID" type="xs:string" minOccurs="0" />
                            <xs:element name="VehicleUsed" type="xs:unsignedInt" minOccurs="0" />
                         </xs:sequence>
                      </xs:complexType>
                   </xs:element>
                   <xs:element name="Staff">
                      <xs:complexType>
                         <xs:sequence>
                            <xs:element name="StaffID" type="xs:unsignedInt" minOccurs="0" />
                            <xs:element name="Rank" type="xs:string" minOccurs="0" />
                            <xs:element name="LastName" type="xs:string" minOccurs="0" />
                            <xs:element name="FirstName" type="xs:string" minOccurs="0" />
                         </xs:sequence>
                      </xs:complexType>
                   </xs:element>
                </xs:choice>
             </xs:complexType>
          </xs:element>
       </xs:schema>
       <Call>
          <CallID>890</CallID>
          <StaffID>134</StaffID>
          <VehicleUsed>12</VehicleUsed>
       </Call>
       <Call>
          <CallID>965</CallID>
          <StaffID>228</StaffID>
          <VehicleUsed>4</VehicleUsed>
       </Call>
       <Call>
          <CallID>740</CallID>
          <StaffID>1849</StaffID>
          <VehicleUsed>2</VehicleUsed>
       </Call>
       <Staff>
          <StaffID>134</StaffID>
          <Rank>Captain</Rank>
          <LastName>Renolyds</LastName>
          <FirstName>Malcom</FirstName>
       </Staff>
       <Staff>
          <StaffID>228</StaffID>
          <Rank>Lieutenant</Rank>
          <LastName>Brown</LastName>
          <FirstName>Bill</FirstName>
       </Staff>
       <Staff>
          <StaffID>1849</StaffID>
          <Rank>Sergeant</Rank>
          <LastName>John</LastName>
          <FirstName>Pepper</FirstName>
       </Staff>
    </ExagoData>

# OLAP and MDX Queries

Exago can query OLAP Data Sources using MDX Queries. OLAP Data Sources and Objects are identical to a regular data base type object, with the following exceptions.

- OLAP Data Objects will always be MDX Queries written in the Custom SQL Object
- Data Objects must have Schema Access Type set to Metadata and must have Column Metadata set for all fields.

# ODBC Drivers

Exago can use ODBC drivers to connect to Data Sources. When connecting to an ODBC data source an extra option will appear to set the Column Delimiter(s). The delimiter character depends on which type of data base you are connecting to.

### Examples

MySql

    ' (grave accent)

MsSql, OLAP

    [] (brackets)

DB2, Informix, Oracle, Postgres, Sqlite

    " (quotation marks)

If you don't know which delimiter character to use, contact your database administrator.

Caution. If your data objects have spaces in their names, you must set the correct delimiter in order to access the data. Otherwise, improper SQL will be generated and you will see errors or erroneous data.