Crystal Reports和C#的存储过程问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Crystal Reports和C#的存储过程问题相关的知识,希望对你有一定的参考价值。

我有一个问题是使用存储过程生成水晶报告。

这不起作用:

CREATE PROCEDURE [dbo].[GetPEBalDeliveryAssn] 
    @Assn VARCHAR(50), 
    @cropseason INT

IF @Assn = 'ALL'  
BEGIN
    SELECT     
        dbo.vDelFarReapGrpCodeBsiCode.farmer_pay_bsi, 
        dbo.vDelFarReapGrpCodeBsiCode.reaping_code, 
        dbo.vDelFarReapGrpCodeBsiCode.farmer_pay_name, 
        dbo.vDelFarReapGrpCodeBsiCode.delivered, 
        dbo.vDelFarReapGrpCodeBsiCode.number_deliveries, 
        dbo.FarmerGroups.PROD_EST,        
        dbo.vDelFarReapGrpCodeBsiCode.CropSeasonsID
    FROM  
        dbo.FarmerGroups 
    INNER JOIN 
        dbo.vDelFarReapGrpCodeBsiCode ON dbo.FarmerGroups.BSI_CODE = dbo.vDelFarReapGrpCodeBsiCode.farmer_pay_bsi                   
    WHERE
        dbo.FarmerGroups.CROP_SEASON = @cropseason 
        AND dbo.vDelFarReapGrpCodeBsiCode.CropSeasonsID = @cropseason                
    ORDER BY 
        dbo.vDelFarReapGrpCodeBsiCode.reaping_code
END

但这样做

CREATE PROCEDURE [dbo].[GetPEBalDeliveryAssn] 
     @Assn VARCHAR(50), 
     @cropseason INT

    IF @Assn = 'ALL' AND @cropseason = 1
    BEGIN
        SELECT     
            dbo.vDelFarReapGrpCodeBsiCode.farmer_pay_bsi, 
            dbo.vDelFarReapGrpCodeBsiCode.reaping_code, 
            dbo.vDelFarReapGrpCodeBsiCode.farmer_pay_name, 
            dbo.vDelFarReapGrpCodeBsiCode.delivered, 
            dbo.vDelFarReapGrpCodeBsiCode.number_deliveries, 
            dbo.FarmerGroups.PROD_EST,       
            dbo.vDelFarReapGrpCodeBsiCode.CropSeasonsID
        FROM  
            dbo.FarmerGroups 
        INNER JOIN 
            dbo.vDelFarReapGrpCodeBsiCode ON dbo.FarmerGroups.BSI_CODE = dbo.vDelFarReapGrpCodeBsiCode.farmer_pay_bsi                   
        WHERE
            dbo.FarmerGroups.CROP_SEASON = 1 
            AND dbo.vDelFarReapGrpCodeBsiCode.CropSeasonsID = 1                
        ORDER BY 
            dbo.vDelFarReapGrpCodeBsiCode.reaping_code
    END

我不确定为什么让@cropseason无效并且有一个实际的1。

答案
SET @cropseason = isnull(@cropseason,0)

以上是关于Crystal Reports和C#的存储过程问题的主要内容,如果未能解决你的问题,请参考以下文章

具有函数 ORA-08103 的 Oracle 存储过程

数据库登录失败:Crystal Reports

使用Crystal Reports ReportDocument

配置 Crystal Reports 所需的帮助

Crystal Reports:根据报表用户定义预设参数

Crystal Reports,从特定位置获取时间