I was tasked with making a Webpage (aspx), which automaticly reads rdlc
s, and generates a webpage, with the parameters at the top as webelements and the report as the main part of the page.
So far, I have tried reading the file as an XML-Doc, and just parsing the info out of there. But this may be done simpler. (I have no expirience with reports or rdl(c)
files).
I have seen that there is a DataSets/DataSet/Query/CommandText
-Tag, which can hold an SQL-Statement. Now this let's my boss and myself assume, that it is possible to make it already deliver this info by itself, which me coding this. On the other hand, I see nowhere any example for that.
My current code looks like this:
private string rdlcFilepath = "some/path/to/file.rdlc";
protected void Page_Load(object sender, EventArgs e) {
string sql = GetSqlStatementFromRdlcFile(rdlcFilepath);
DataTable dtTest = DatabseFacade.Execute_SQL(sql);
MainReportViewer.LocalReport.ReportPath = Server.MapPath(rdlcFilepath);
MainReportViewer.ProcessingMode = ProcessingMode.Local;
MainReportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dtTest));
MainReportViewer.LocalReport.Refresh();
}
So, I have 2 theories:
- The
CommandText
-Tag tag is a ment for a "report server" and should be used only inProcessingMode.Remote
, and is not relevant when in Local mode. - I'm approaching this whole thing wrong.
If 2 is true, then probably the problem is manually adding the dtTest
, and it should have some other instruction to make the report-element "pull" the data by itself.
My questions:
- Is one of my assumptions correct, or what is going on?
- Any other hints/links that may help?
I may note, that every tutorial/example I saw on the internet, that used ProcessingMode.Local
, used an "external" datatable, and the LocalReport.DataSources.Add
way.
Just for clearification, our (my boss' and my) ideal solution, would be some "magic" command, that makes the ReportViewer, use the information in the rdlc
file, to connect to the database, and display the result. After all it contains all of the info, from connection-string to SQL-statement.