Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 4th, 2003, 10:12 AM
Authorized User
 
Join Date: Nov 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Having problems returning total rows to asp

Hi,

Below is a SP that I am using to poulate a temp table with selected records for paging through within an asp page.

I have tried to use @@ROWCOUNT AND COUNT but I can't seem to get the syntax correct I have tried

select count("row_id") as totalrecords but this just returns the value of one.

Every thing else I have tried just produces the "Item cannot be found in the collection corresponding to the requested name or ordinal" error on the asp page. Can anybody help with getting the number of rows returned from this temp table?

There is already a COUNT torwards the bottom of the SP but I can't seem to access it's value and pass it into the asp page

Thanks for any help
peter




CREATE PROCEDURE dbo.employee_cil_page
    (
     @Page INT,
     @RecsPerPage INT,
     @NID VARCHAR(3),
     @CID VARCHAR(10),
     @EMP VARCHAR(10)
    )
AS
SET NOCOUNT ON


--Create a temporary table
CREATE TABLE #CILTempItems
(
    myID INT IDENTITY,
    row_id INT,
    NETWORK_ID VARCHAR(3),
    NODE_ID VARCHAR(5),
    CORP_ID VARCHAR(10),
    EMP_ID VARCHAR(10),
    CIL_ID VARCHAR(20),
    CIL_TYPE VARCHAR(1),
    CIL_KEY VARCHAR(10),
    CIL_DESC VARCHAR(20),
    CIL_BILL_FLAG VARCHAR(1),
    RENTAL VARCHAR(1),
    START_DATE datetime,
    END_DATE datetime,
    username VARCHAR(50),
    action_date datetime,
    user_action CHAR(1)

)


-- Insert the rows from tblItems into the temp. table


INSERT INTO #CILTempItems (row_id,NETWORK_ID,NODE_ID,CORP_ID,EMP_ID,CIL_ID,C IL_TYPE,CIL_KEY,CIL_DESC,CIL_BILL_FLAG,RENTAL,STAR T_DATE,END_DATE,username,action_date,user_action)

SELECT row_id,NETWORK_ID,NODE_ID,CORP_ID,EMP_ID,CIL_ID,CI L_TYPE,CIL_KEY,CIL_DESC,CIL_BILL_FLAG,RENTAL,START _DATE,END_DATE,username,action_date,user_action

FROM Employee_cil

WHERE NETWORK_ID = @NID AND CORP_ID= @CID AND EMP_ID = @EMP


-- Find out the first and last record we want
DECLARE @FirstRec int, @LastRec int
SELECT @FirstRec = (@Page - 1) * @RecsPerPage
SELECT @LastRec = (@Page * @RecsPerPage + 1)


-- Now, return the set of paged records, plus, an indiciation of we
-- have more records or not!
SELECT *,
       MoreRecords =
    (
     SELECT COUNT(*)
    FROM #CILTempItems TI
    WHERE TI.myID >= @LastRec

    )
FROM #CILTempItems
WHERE myID > @FirstRec AND myID < @LastRec

-- Turn NOCOUNT back OFF
SET NOCOUNT OFF
GO


 
Old December 9th, 2003, 12:59 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

When you run SQL that returns more than one set of rows, the ADODB recordset object in ASP will actually contain multiple recordsets. I think you can call it like this:

Set objRecordSet = objRecordSet.NextRecordset()

This will advance and return to the next recordset in the collection. You can then access the fields in the second part of your SPROC.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
adding all the rows to get a total value KeviJay SQL Language 2 May 29th, 2008 03:22 AM
Problems with multiple total query. cstooch Classic ASP Databases 0 May 14th, 2006 02:09 PM
Problems returning count in Stored Procedure planza SQL Language 1 December 21st, 2005 03:24 PM
total number of rows in a recordset lian_a Classic ASP Basics 2 February 8th, 2005 08:13 AM
Problems With returning records through ADO marko_one Classic ASP Databases 5 September 30th, 2004 04:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.