开发者

How do Microsoft reports (RDL) query the data?

I am not creating RDL from scratch so maybe this is a probl开发者_开发百科em -- I work on already prepared files.

MSDN states that CommandText in RDL file can contain T-SQL query. Ok, this I understand, but what else it can contains?

I am asking because the phrasing clearly indicates you can put some other expression there So if I understand correctly, I can look at RDL code (in Visual Studio, RMB on RDL file, "view code") and the interesting parts would be...?

  • DataSourceName -- this is a "link" to database via definitions of data sources
  • CommandText -- I thought this is the place to put query, like SELECT... but from what I see there are no queries used


Reporting service, loads the rdl file into it, and starts parsing and reading the command according to their sections like

data source, report params, etc.

gets the values of params (if any). start using the data source database connection. execute the query/ sp command. get the data, and store in seperate data fields which are also mentioned in rdl. binds their values with controls (text box, grid columns etc), if there is any expression written into it, execute them as well.

Generate the output (html/ pdf).

And there you Go.

I just tried to explain in short and simple words. you can check out msdn for complete detail.

Regards,

Mazhar Karimi


You can create reports manually and fill them with any data that you would like to.

Sth like:

ReportDataSource reportDataSource = new ReportDataSource();
reportViewer.Reset();
reportDataSource.Name = "DataSetOdczyty_klienci_adresy";
reportDataSource.Value = klienciadresyBindingSource;
reportViewer.LocalReport.DataSources.Add(reportDataSource);
reportViewer.LocalReport.ReportEmbeddedResource = "Wodociagi.Reports.ReportListaKlientow.rdlc";


You can open the report file *.rdl with an XML editor like Notepad++. Then, search for <DataSets> and you will find the datasets used in the report.

  • The field names of each data set are in the <Fields> section
  • In the <Query> section of each data set you can find <CommandText> and <QueryParameters> as shown in the example below

Example:

  <Query>
    <DataSourceName>MyDataSource</DataSourceName>
    <CommandType>StoredProcedure</CommandType>
    <CommandText>usp_QueryCustomers</CommandText>
    <QueryParameters>
      <QueryParameter Name="@CustomerId">
        <Value>=Parameters!PersSysId.Value</Value>
      </QueryParameter>
      <QueryParameter Name="@RowsCnt">
        <Value>=Parameters!RowsCnt.Value</Value>
      </QueryParameter>
    </QueryParameters>
  </Query>

I didn't find a way to see that in Visual Studio's report editor easily. Maybe the bounty I have started helps here (does someone like to earn the 50 reputation points)?


Initially, I was not sure why both the OP and @Matt are reading the XML directly instead of editing the query in Visual Studio (I only resort to that in extreme cases). But now I think you might have failed victims of the missing "Report Data" pane.

Open the report in Visual Studio BIDS like normally, then from View menu select "Report Data". If it's not there, click on the report canvas anywhere, then it should appear. In the "Report Data" pane that will appear, you're interested in Data Sources (where's the data coming from?) and Datasets (what are the queries, parameters, expressions?).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜