0
votes

Is it possible to design a completely standalone RDLC report?

By that, I mean that the host application driving the ReportViewer control might pass in a connection string, but every other aspect (in particular, including the SQL queries) must be defined inside the RDLC file, with no predefined DataSets etc in the code.

Essentially, what I'm looking for is something where the code knows how to connect to the database, but the report file is in complete control of which tables to fetch data from and how to join them. So that you can drop a new RDLC file in without touching any of the code and it can report on completely different tables than any previous reports.

Everything I can find about RDLC talks about making typed datasets or populating DataTables in code, which is not what I want.

I did notice that there appears to be a CommandText value in the file, which seems promising, but I can't find any way to set this in the RDLC designer, nor does it appear to actually do anything.

I'm sure I must be missing something fundamental here (for background, I'm most familiar with Crystal Reports, which behaves as I am wanting above). I can't imagine how writing additional code could be a requirement to write additional reports.

1

1 Answers

0
votes

This does not entirely answer the question, however it's the best answer I have so far.

It's possible to use Report Builder to create an RDL file which contains an embedded query.

(However it doesn't seem to be possible to use subreports with it without a Report Server.)

Taking this file and renaming it to .rdlc produces something that will successfully parse and run as a local report, except that there doesn't appear to be any way to access the embedded SQL in the CommandText. It also annoys the RDLC designer which doesn't recognise it as a valid Dataset, although as long as you don't try to modify the dataset inside the designer then this doesn't seem to matter. (And even if you do, this doesn't appear to alter the CommandText, which can be both good and bad.)

It should theoretically be possible to manually parse the file, extract the CommandText, execute the query, and then feed that back into the local report viewer as a DataTable. Why is this not a thing that Just Works™?