Monday, May 23, 2011

Connecting ActiveReports to alternate DataSources


We can connect ActiveReports to any datasource that a .NET object can connect to. The fact that has to be taken care of during this is that we provide a valid connection string and a valid sql statement to the reports designed so. The following link has a list of connection strings

http://connectionstrings.com/

Once a valid connection string and sql statement has been provided to ActiveReports, the list of field values would be populated which you can now drag inside the report and create a report design and run the same.

For the sake of illustration,please refer to the sample application at this link. It contains two reports,one connecting to an Excel file and the other connecting to a comma delimited text file in the DataSource folder at the root of the project.Both the reports use the Microsoft.Jet.Oledb provider to connect to the respective files.

An important point worth mentioning is that on connection to an Excel file ,the SQL to be written should be of something in this format.

Select * from [Sheet1$]

Here Sheet1 happens to be the name of the Sheet in the Excel File that contains the data to be consumed by the report and it has to follow by a dollar($) sign.

No comments:

Post a Comment