簡體   English   中英

SSRS Report Viewer不檢測數據源?

[英]SSRS Report Viewer doesn't detect datasource?

我在ReportBuilder 3.0中構建了一個非常簡單的報告(.rdl)。 它與我的數據庫有連接,並從地址字段中獲取城市。

SELECT TOP 10 City, COUNT(City) FROM [MYDB].[dbo].[ResidentialAddress] WHERE StateName = 'WA' OR StateName = 'Washington' GROUP BY City ORDER BY COUNT(City) DESC

這適用於ReportBuilder。 我保存並關閉。 然后我嘗試通過MicroSoft.Reporting.WebForms.ReportViewer在VS 2010中打開並查看報告。 我可以在我的c#/ ASP.NET網站本地加載一個完全空白的RDL文件(僅文本)。

            this.MyReportViewer.Reset();
            this.MyReportViewer.ProcessingMode = ProcessingMode.Local;
            this.MyReportViewer.AsyncRendering = false;
            this.MyReportViewer.LocalReport.LoadReportDefinition(new StreamReader("H:\\DataReportsViewer\\DataReportsViewer\\" + RDLFileList.SelectedValue));
            this.MyReportViewer.LocalReport.ReportPath = RDLFileList.SelectedValue;          
            this.MyReportViewer.ShowReportBody = true;
            this.MyReportViewer.LocalReport.Refresh();

但是,只要我添加圖表,我就會收到此錯誤:

尚未為數據源“DataSet1”提供數據源實例。

這對我來說沒有意義,因為當我打開RDL文件時,連接字符串和查詢就在那里,看起來應該是這樣。

<DataSources>
    <DataSource Name="DataSource1">
      <ConnectionProperties>
        <DataProvider>SQL</DataProvider>
        <ConnectString>Data Source=MYSERVER;Initial Catalog=Ad_Dev</ConnectString>
        <IntegratedSecurity>true</IntegratedSecurity>
      </ConnectionProperties>
      <rd:SecurityType>Integrated</rd:SecurityType>
      <rd:DataSourceID>350f6976-9402-43fd-b8f8-8f809f116f84</rd:DataSourceID>
    </DataSource>
  </DataSources>
  <DataSets>
    <DataSet Name="DataSet1">
      <Query>
        <DataSourceName>DataSource1</DataSourceName>
        <CommandText>SELECT TOP 10 ResidentialAddress.City,COUNT(ResidentialAddress.City)
FROM ResidentialAddress
WHERE StateName = 'WA'
GROUP BY ResidentialAddress.City
ORDER BY COUNT(ResidentialAddress.City)</CommandText>
        <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
      </Query>
      <Fields>
        <Field Name="City">
          <DataField>City</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="ID">
          <DataField />
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
  </DataSets>

所以,我在我的c#代碼中嘗試了解決方法:

            //Added line: TestDataSource runs same query and returns correctly loaded DataTable
            ReportDataSource reportDataSource = new ReportDataSource("DataSet1", TestDataSource()); 
            this.MyReportViewer.LocalReport.DataSources.Add(reportDataSource);

而且運行,但沒有數據出現。 我不能贏! :(

有任何想法嗎? SSRS和ASP.NET是不是意味着互相玩耍? 我本來希望制作一個本報告查看器的本地測試版本,但我已經不得不做很多黑客甚至讓空白報告在本地運行。

在本地處理模式中,必須通過調用代碼來提供數據集,即主機程序必須執行所有查詢並將該數據傳遞給報表查看器。 以下是http://www.gotreportviewer.com/definedata/index.html上的示例另外,任何數據都可以傳遞到報告查看器( http://www.gotreportviewer.com/objectdatasources/index.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM