Search code examples
c#reporting-servicesreportingservice

How do I dynamicaly create an SSRS Report?


Im trying to create a report in SSRS. The report calls a stored procedure for its data. I want to display the data in a table. But the thing is, the result from the stored procedure differs from time to time, because every customer has its own 'template'. This means the result for customer A could be :

AccountNumber | CustomerID
1234567890           0987654321
1579086421           1234565465
......................          ....................

and for customer B could be:

CustomerName | Address
Customer B          Teststreet 1
Customer Test     Teststreet 2
......................      ....................

There are 50 different columns to choose from. The order of the columns is also editable. My stored procedure takes care of this. The only thing I want is to put the resultset of the storedprocedure 1:1 in my report (header+body). Do you guys know how to do this?

If thats not possible, is there a C# solution to this? I.e creating a report object in C#, adjust settings etc.

Thanks


Solution

  • You can create the SSRS report dynamically based on the data set returned by the stored procedure. The report format (RDL) is documented and its an XML format. So you can use System.XML namespace to generate RDL. Alternate (and unsupported) way is to refer RDL object model assembly (Microsoft.ReportingServices.RdlObjectModel) - you can locate the assembly on SSRS 2008 server machine and copy it on your local machine. It offers an object model to read/generate RDL.

    I have adopted approach where RDL is generated (as XML) dynamically based on the data-table and then publish the RDL on SSRS server using web services API.