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

问题描述 投票:0回答:1

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

这不起作用:

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。

c# stored-procedures crystal-reports
1个回答
0
投票
SET @cropseason = isnull(@cropseason,0)
© www.soinside.com 2019 - 2024. All rights reserved.