How to access data source using scripts

How to access data source using scripts

In this tutorial, we will learn how to access a report data source using scripts.


Let’s assume we have a report, its data source is set in the ReportManager and we need to access a separate record or field from one of the tables.

To demonstrate how to do that, let’s take a specific sample: we have the Customers data source. One of its tables is passed to the ReportManager component, and one of the fields of the table is “CompanyName”.

To access this field you can take advantage of the code sample below:

System.Data.DataTable tbl;

System.Windows.Forms.MessageBox.Show(Engine.Objects["Customers"].GetType().ToString());

tbl = Engine.Objects["Customers"] as System.Data.DataTable;

System.Windows.Forms.MessageBox.Show(tbl.Rows[0]["CompanyName"].ToString());


Add Feedback