2014-09-19 77 views
0

這是我的存儲過程。在Crystal Report 2010的運行時傳遞參數

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(); 

我沒有想法解析在運行時間參數。

在此代碼顯示另一個彈出窗口來運行時。我需要在運行時給出這些參數。

回答

0

分配給報表源之前,調用SetParameterValue與名稱和值的每個參數

rptBurndown.SetParameterValue("ParameterName", value); 
+0

感謝ü@reckface!但它不起作用!那個彈出窗口再次出現。 – 2014-09-19 06:36:15

+0

什麼窗口,彈出窗口是什麼意思?嘗試調用一次SetLogonInfo,並臨時註釋每條語句以應用登錄信息並查看會發生什麼。 – reckface 2014-09-19 06:41:37

+0

這裏沒有問題!彈出窗口要求填寫date1和date2字段!現在小數部分顯示爲這樣#####在另一份報告中我該怎麼辦? – 2014-09-19 06:56:07