SSRS ReportViewer problems with XML embedded data source

前端 未结 3 810
北荒
北荒 2021-01-26 03:41

I have C# (WPF) application where I want to display a SSRS report in the ReportViewer control. The local report file has XML datasource embedded in it. The report is displayed c

相关标签:
3条回答
  • 2021-01-26 03:55

    The answer to my question can also be found here When to use RDLC over RDL reports? and here http://www.gotreportviewer.com/. It's basically this:

    Unlike the Report Server the ReportViewer control does not connect to databases or execute queries. Also, in local mode the only export formats available are Excel, Word and PDF. (In remote mode all formats supported by the Report Server are available.) The ReportViewer control cannot be extended by adding custom renderers or custom report items.

    More information can be found here http://msdn.microsoft.com/en-us/library/ms252109(v=vs.80).aspx.

    The ReportViewer control, which processes .rdlc files, ignores the element of RDL. If a report definition contains a query, the control will not process it.

    and

    When converting a .rdl file to .rdlc format, you must manually replace the data source and query information in the report definition with data constructs provided in your application

    So you have to fetch the data explicitly and provided for the ReportViewer as a ReportDataSource having the exact same name as the dataset in the RDL file.

    0 讨论(0)
  • 2021-01-26 04:20

    I have a small command line app that does something similar, but between defining the report path and doing anything with the report viewer I'm setting a data source for the report to be run against:

    report.DataSources.Add(new ReportDataSource("DataSet_for_Distribution", table));
    

    ...table is a DataTable.

    After that I have no problems programmatically calling the report Render method.

    Can you set a break before the render and see what data sources the report actually has?

    Another thing to try, and it may just be that you formatted (or stack formatted ) it to post it here, but when I embed an XML data set in a report it is all using a format like this:

    <CommandText>&lt;Query&gt;
        &lt;ElementPath&gt;Root /S  {@OrderDate (Date), @TotalDue (Decimal)} /C {@LastName} &lt;/ElementPath&gt;
        &lt;XmlData&gt;
        &lt;Root&gt;
        &lt;S OrderDate="2003-07-01T00:00:00" SalesOrderNumber="SO51131" TotalDue="247913.9138"&gt;
          &lt;C FirstName="Shu" LastName="Ito" /&gt;
        &lt;/S&gt;
        &lt;S OrderDate="2003-10-01T00:00:00" SalesOrderNumber="SO55282" TotalDue="227737.7215"&gt;
          &lt;C FirstName="Shu" LastName="Ito" /&gt;
        &lt;/S&gt;
        &lt;S OrderDate="2002-07-01T00:00:00" SalesOrderNumber="SO46616" TotalDue="207058.3754"&gt;
          &lt;C FirstName="Jae" LastName="Pak" /&gt;
        &lt;/S&gt;
        &lt;S OrderDate="2002-08-01T00:00:00" SalesOrderNumber="SO46981" TotalDue="201490.4144"&gt;
          &lt;C FirstName="Ranjit" LastName="Varkey Chudukatil" /&gt;
        &lt;/S&gt;
        &lt;S OrderDate="2002-09-01T00:00:00" SalesOrderNumber="SO47395" TotalDue="198628.3054"&gt;
          &lt;C FirstName="Michael" LastName="Blythe" /&gt;
        &lt;/S&gt;
        &lt;/Root&gt;
        &lt;/XmlData&gt;
        &lt;/Query&gt;</CommandText>
    
    0 讨论(0)
  • 2021-01-26 04:21

    I am not sure from what you have stated if the data source has specified credentials.

    This part here:

    <ConnectionProperties>
                <DataProvider>XML</DataProvider>
                <ConnectString />
              </ConnectionProperties>
    

    Generally speaking with SQL data sources when reports fail to view for others or from applications it is due to the hosting server assuming a different credential than your IDE building the application. It does not know if my name is Brett, that my credentials are running it when calling it remotely. When you specify the credentials on the server hosting the report you can usually get around this. You go into the server hosting the report, I assume you are doing this as you have an 'rdl' report versus an rdlc report. Find the datasource, click properties, change setting to be 'use these credentials'. Supply credentials that you know work.

    This may fix the issue. I am not certain with Sharepoint connections and XML connections but this is common with viewing issues with SQL Server connections.

    0 讨论(0)
提交回复
热议问题