在crystal report 2010中的运行时传递参数

时间:2014-09-19 05:24:29

标签: crystal-reports

这是我的存储过程。

USE [DataStock]
GO

/****** Object:  StoredProcedure [dbo].[getBillData]    Script Date: 09/19/2014 10:47:21 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[getBillData]    

@date1 varchar(20),

@date2 varchar(20)



AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here

    SELECT DISTINCT      [Billlist].[billno] [Bill No.],    temp.[BillDate] [Date],    [Billlist].[user] [Customer Name],    [Billlist].[total] Total,    [paid] Paid,    [discount] Discount FROM temp  JOIN [Billlist] ON temp.[billno] = [Billlist].[billno] WHERE temp.[BillDate] BETWEEN @date1 and @date2

END
GO

我的水晶报告代码是,

Report.BillListReport rptBurndown = new Report.BillListReport();
            CrystalDecisions.Shared.ConnectionInfo crDbConnection = new CrystalDecisions.Shared.ConnectionInfo();
            crDbConnection.IntegratedSecurity = true;
            crDbConnection.DatabaseName = "DataStock";
            crDbConnection.ServerName = ChangeableFields.ServerName;
            CrystalDecisions.CrystalReports.Engine.Database crDatabase = rptBurndown.Database;
            CrystalDecisions.Shared.TableLogOnInfo oCrTableLoginInfo;
            foreach (CrystalDecisions.CrystalReports.Engine.Table oCrTable in
              crDatabase.Tables)
            {
                oCrTableLoginInfo = oCrTable.LogOnInfo;
                oCrTableLoginInfo.ConnectionInfo = crDbConnection;
                oCrTable.ApplyLogOnInfo(oCrTableLoginInfo);
            }

            crystalReportViewer1.ReportSource = rptBurndown;
            crystalReportViewer1.RefreshReport();

我没有想法在运行时解析参数。

在此代码中显示另一个弹出窗口,当它运行时。我需要在运行时给出这些参数。

1 个答案:

答案 0 :(得分:0)

在分配到报告源之前,请为每个参数调用SetParameterValue,其名称和值为

rptBurndown.SetParameterValue("ParameterName", value);