2012-12-14 45 views
6

我想加載一個報告,在textbox1中按名稱過濾,但我收到錯誤「試圖設置報告參數'名稱',但未在此報告中定義」任何想法?嘗試設置報告參數「名稱」,該報告未在此報告中定義?

Dim ds As New TestDataSetTableAdapters.tblTestDataTableAdapter 

     ' Create report data source 
     Dim ID As ReportParameter 
     ID = New ReportParameter("Name", TextBox1.Text) 

     Dim rds As New ReportDataSource("MyApplication_ModelObject", ObjectDataSource1) 

     ' Clear the datasets in the report viewer and add the new datasource 
     ReportViewer1.LocalReport.DataSources.Clear() 
     ReportViewer1.LocalReport.DataSources.Add(rds) 
     ReportViewer1.LocalReport.SetParameters(ID) 
     ReportViewer1.LocalReport.Refresh() 

回答

3

ReportParameterName部分必須在報告中參數的名稱相匹配。

這可能是@Name,最好做的是打開報告並在那裏查看。

+0

感謝修復了這個錯誤,但是現在當我的報告加載時,除了一條消息說沒有爲數據源'DataSet1'提供數據源實例。 – user1342164

+0

爲這個問題開了一個新問題,可能是很多東西,但憑據相當相似。 – Stuart