views:

136

answers:

0

Hi

I have a SP (shortened version):

    CREATE PROCEDURE [dbo].[usp_ADMIN_CountExposure]
             @whereAge int
        ,@whereGender int
        ,@whereSalary int
    AS
    BEGIN

        SET NOCOUNT ON;

    DECLARE @query varchar(max)
        SET @query = 'SELECT [ID], SUM([Lives]) AS [Lives] 
            FROM [ExpDB].[dbo].[ExposureView] '

    IF (@whereAge = 1 OR @whereGender = 1  OR @whereSalary = 1 )

    BEGIN
        SET @query = @query + 'WHERE '
    END

    IF @whereAge = 1

    BEGIN
        SET @query = @query + '[Age Band]= ''Unknown'' '
    END


    SET @query = @query + 
        ' GROUP BY [ID] ORDER BY [ID]'

    EXEC(@query)
    END

I am trying to use this to select data with SubSonic 3.0 using:

   var dataSet = db.UspADMINCountExposure(1, 0, 0).ExecuteDataSet();

But I keep getting the error:

   "Procedure or function 'uspADMINCountExposure' expects parameter '@whereAge', 
     which was not supplied."

If I just use .Execute() no such error occurs

Thanks