开发者

How do I specify parameters to a SP and to the report?

开发者 https://www.devze.com 2023-01-10 23:10 出处:网络
I think I\'ve got a fundamental misunderstanding going on, concerning a SQL Server Reporting Services report, which I\'m trying to make run locally in a WinForms app (eventually it will be in a WPF ap

I think I've got a fundamental misunderstanding going on, concerning a SQL Server Reporting Services report, which I'm trying to make run locally in a WinForms app (eventually it will be in a WPF app, but that's later). I'm don't write many reports, and whenever I have in the past, I've used Crystal Reports. But we're trying to get away from Crystal.

Anyway, the report I'm working with uses a stored procedure in SQL Server. This SP takes 2 parameters. I also want to pass some parameters to the report itself, things like the title, etc. It's been a long time since I've done this with Crystal, but it seems to me that what I did was configure the parameters to the Crystal report, to accept parameters both for the SP and for the report, and then within the Crystal designer assign which parameter goes where. So, I tried doing the same thing with my new .RDLC report, but that's not working. When the report gets displayed in the ReportViewer control on the form, it says:

"The 'ClientNumber'开发者_如何学编程 parameter is missing a value."

ClientNumber is one of the parameters to the SP. And that table adapter seems to be supplying it, in the Fill method. So, I'm wrong about how this works. So then, how do I assign values to the parameters of the report?


in rdlc reports you must run sp by a data provider like SqlCommand, then you must make a named dataset, after that you can fill dataset with SqlCommand returned data. please see the below:

private void PrintBankReport(ReportDataSource rds)
{
    rds.Name = Constants.Accounting.ClientReportDataSourceName.BankReportDS1;
    rds.Value = ((BankReportDataSet)Session[Faraconesh.Portal.Common.Constants.Accounting.Session.BankReport]).ReportDetail;
    ReportViewerControl.LocalReport.DataSources.Add(rds);
    ReportDataSource rds2 = new ReportDataSource();
    rds2.Name = Constants.Accounting.ClientReportDataSourceName.BankReportDS2;
    rds2.Value = ((BankReportDataSet)Session[Faraconesh.Portal.Common.Constants.Accounting.Session.BankReport]).ReportItem;
    ReportViewerControl.LocalReport.DataSources.Add(rds2);
}

but in rdl reports (server report) you can pass a sp to a report as a datasource and report can specify the parameters automatically.

0

精彩评论

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