ASP, ADO and Paging - Not Working



Hi all...I have a stored proc that works fine except I can't get the
paging property to work in ASP. It seems that because I'm building the
SQL withing the SP is causing the problem. If I don't build the SQL as
a string paging works. In my ASP page, the pagecount property returns
-1 for some reason.


Here's the proc:

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

ALTER Procedure LS_DisplayAllCategoriesBoolean
@aSections varchar(255),
@field varchar(255)


As

declare @sql varchar(1000)
SET NOCOUNT ON

set @sql = 'SELECT DISTINCT ls_product_catalog.id,
ls_product_catalog.ItemNumber, ls_product_catalog.Name,
ls_product_catalog.[Descriptor], ls_product_catalog.Price,
ls_product_catalog.Shade_Name, ls_product_catalog.Sale_Price,
ls_product_catalog.Sale_Desc
FROM dbo.ls_brand INNER JOIN
dbo.ls_product_catalog ON dbo.ls_brand.nID =
dbo.ls_product_catalog.CategoryID INNER JOIN
dbo.ls_product_category ON dbo.ls_product_catalog.id =
dbo.ls_product_category.nProductID
WHERE dbo.ls_brand.bVisible = 1 and
dbo.ls_product_category.nCategoryID in (Select IntValue
from dbo.CsvToInt(''' + @aSections + ''') ) '


if @field = 'bNew'
begin
set @sql = @sql + ' AND bNew = 1 AND
(dbo.ls_product_catalog.bGiftOnly is null or
dbo.ls_product_catalog.bGiftOnly = 0)'
set @sql = @sql + ' order by ls_product_catalog.[Descriptor]'
end
if @field = 'bGift'
begin
set @sql = @sql + ' AND bGift = 1 or bGiftOnly =1'
set @sql = @sql + ' order by ls_product_catalog.[Descriptor]'
end


if @field = 'bGiftOnly'
begin
set @sql = @sql + ' AND bGiftOnly= 1'
set @sql = @sql + ' order by ls_product_catalog.[Descriptor]'
end

if @field = 'sale_price'
begin
set @sql = @sql + ' AND (sale_price is not null OR sale_desc is not
null)'
set @sql = @sql + ' order by ls_product_catalog.Name'
end





exec(@sql)
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

.



Relevant Pages

  • SP and ADO Page Property Not Working Properly
    ... Hi all...I have a stored proc that works fine except I can't get the ... paging property to work in ASP. ... SQL withing the SP is causing the problem. ... In my ASP page, the pagecount property returns ...
    (comp.databases.ms-sqlserver)
  • ASP ADO SP call returning closed recordset
    ... This was originally posted to comp.databases.ms-sqlserver, but no response ... Can anybody tell me why a) when running a stored proc from an asp page to ... 'execute the SP returning the result into a recordset ...
    (microsoft.public.sqlserver.programming)
  • Passing comma seperated values to a stored proc
    ... They can type in multiple IDs if they are seperated ... I want to pass this string into a Stored Proc and just use an ... "in" command in the where clause to return a recordset back to the ASP page. ... "Syntax error converting the varchar value '123456,123457,123458' to a ...
    (microsoft.public.sqlserver.programming)
  • Re: sp_xml_removedocument cant find handle
    ... The handle lives until the connection is reset. ... stored proc and call that instead of doing this inside an ASP page by ... > Microsoft OLE DB Provider for SQL Server error '80040e14' ...
    (microsoft.public.sqlserver.xml)