Create a Data Source with the .NET API

The following is a quick explanation for how to create a Data Source using the .NET Api.


First, ensure that your application is referencing the DataSource class, which is located in the WebReports.Api.Data namespace.

using WebReports.Api.Data;


/* Manually Creating a Data Source */

DataSource myDataSource = new DataSource(myApi.PageInfo);

myDataSource.Name = "Northwind";
myDataSource.DbType = "mssql";
myDataSource.Schema = "dbo";
myDataSource.DataConnStr = "Server=DBSERVER;Database=Northwind;uid=admin;pwd=pass;";


NOTE: Data Sources created in the API are unique to their session.

First, create a new Data Source using the following overloaded constructor:

new DataSource(myApi.PageInfo);

The DataSource constructor requires the Api's PageInfo object as the first argument.

Give the data source a name which will appear in the report designer:

myDataSource.Name = "Northwind";

Or you can retrieve an existing Data Source from the current configuration:


This method requires the string "Name" of the Data Source as an argument.

Then set the database type:

myDataSource.DbType = "mssql";

This field accepts the following valid database types as strings:

NOTE: Ensure that you have the correct drivers for the database type.
  • mssql: Microsoft SQL Server
  • mysql: MySQL
  • oracle: Oracle Database
  • postgres: PostgreSQL
  • db2: IBM DB2
  • informix: IBM Informix
  • websvc: Database Web Service
  • assembly: Database Assembly
  • file: Microsoft Excel File
  • msolap: MSOLAP
  • odbc: ODBC

Finally, set the connection string:

myDataSource.DataConnStr = "Server=DBSERVER;Database=Northwind;uid=admin;pwd=pass;";

For more information on database connection strings, see (This is a third party resource, unaffiliated with Exago Inc).

If necessary, you can set the schema/owner name (if left blank, it will use the default):

myDataSource.Schema = "dbo";

Hidden Article Information

Article Author
Exago Development
created 2016-03-10 18:32:06 UTC
updated 2017-02-21 16:46:01 UTC

How Do I, database connection, API, .NET, data sources, How-To,
Have more questions? Submit a request