如何将参数值传递给crystal report的数据源

时间:2016-01-12 10:59:42

标签: vb.net stored-procedures crystal-reports

我有一个存储过程,我把它放在我的水晶报告中

CREATE FUNCTION [dbo].[SP_MainContent]
(       @from int,
        @to int,
        @year int,
        @office varchar(MAX),
        @fund varchar(MAX)
)
RETURNS TABLE
AS
RETURN (
  SELECT AccntTbl.Id,
         AccntTbl.accnt,
         ISNULL(SupplyTbl.Supply, 0) AS Supply,
         AccntTbl.office,
         AccntTbl.exp,                 
         AccntTbl.dateCreated 
  FROM AccntTbl 
  LEFT JOIN
     (SELECT idAccnt, 
             SUM(amount) AS Supply
     FROM SuppyTbl AS SupplyTbl1
     WHERE MONTH(dateCreated) BETWEEN @from AND @to 
       AND YEAR(dateCreated) = @year 
       AND fund = @fund
     GROUP BY idAccnt) AS SupplyTbl     
  WHERE YEAR(AccntTbl.dateCreated) = @year 
    AND AccntTbl.office = @office 
    AND AccntTbl.fund = @fund 
  GROUP BY AccntTbl.Id,
           AccntTbl.accnt,
           AccntTbl.appro,
           Supply.Supply
);

和VB.NET

Dim ad As New SqlDataAdapter("SP_MainContent '" & 1 & "', '" & 2 & "', '" & 2016 & "', " & _
                             "               'office', 'food'", conn)
Dim ds As New DataSet
Dim rpt As New CRreport
ad.Fill(ds, "SP_MainContent")
rpt.SetDataSource(ds)

CrystalReportViewer1.Refresh()
CrystalReportViewer1.ReportSource = rpt

但是每当我打开报告时,这个窗口都会弹出,它太烦人了。

enter image description here

如何阻止此弹出?每当我在vb.net中打开我的报告时

很高兴有任何帮助.tnx:)

1 个答案:

答案 0 :(得分:2)

您应该传递参数值,如下所示

-fno-automatic