Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI i am very new to MVC4 i wrote one stored procedure im trying return dbset but y it returning int .. please help.
the fallowing code is my stored procedure
SQL
Create Procedure [dbo].[Getall] 
     @PageIndex INT = 1
      ,@PageSize INT = 10
      ,@PageCount INT OUTPUT
AS
BEGIN
      SET NOCOUNT ON;
      SELECT ROW_NUMBER() OVER
            (
                  ORDER BY [ID] ASC
            )AS RowNumber
      
       ,[CODE]
      ,[NAME]
      ,[DESCRIPTION_URL]
      ,[FINAL_PRICE]
      ,[OLD_PRICE]
      ,[DISCOUNT_PERCENTAGE]
      ,[IMAGE_URL]
      ,[CREATED_DATE]
     
      
    INTO #Results
      FROM AVAILABLE_OFFER
     
      DECLARE @RecordCount INT
      SELECT @RecordCount = COUNT(*) FROM #Results
 
      SET @PageCount = CEILING(CAST(@RecordCount AS DECIMAL(10, 2)) / CAST(@PageSize AS DECIMAL(10, 2)))
      PRINT       @PageCount
           
      SELECT * FROM #Results
      WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
     
      DROP TABLE #Results
END
Posted
Updated 10-Dec-13 1:53am
v2
Comments
s#@!k 10-Dec-13 8:05am    
It seems your procedure returning two result sets.check once by filling dataset there you can see the number of result sets from database to your code.
Member 10457105 12-Dec-13 3:36am    
thanks amith ya its returning two values.. now i changed the sp. i got the solution
Member 10457105 12-Dec-13 2:34am    
ya i got the solution. thanks amith.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900