February 14, 2007 at 5:34 am
I'm running out of ideas for this one. I have an SP that does multiple selects into table variables and one into a local variable. The last select actually returns the data. It works fine in QA, but I do still get a message "1 rows affected" despite having "set nocount on" in the SP. When I invoke it in my ASP page it returns no data.
Any ideas?
Here's the SP:
ANSI_NULLS ON
QUOTED_IDENTIFIER ON
PROCEDURE [dbo].[GetLeaders]
int,
int
SET NOCOUNT ON;
DECLARE @seqrank TABLE (Points int, Rank int)
.dbo.Visited ON dbo.playerStandings.PlayerID = NCAAIPD.dbo.Visited.visited_id LEFT OUTER JOIN
ON dbo.playerStandings.TotalPoints = R.Points
WHERE dbo.playerStandings.Poolid=@poolid
GROUP BY R.Rank, dbo.playerStandings.PlayerID,
LEFT(NCAAIPD.dbo.Visited.visited_fname, 1)+ '. ' + NCAAIPD.dbo.Visited.visited_lname, NCAAIPD.dbo.Visited.visited_city + ', ' + NCAAIPD.dbo.Visited.visited_state
ORDER BY R.Rank
February 14, 2007 at 6:12 am
When you say it returns no data via asp, I assume you are using some error checking to make sure the returned data isn't actually an error (which would look the same as no data)?
February 14, 2007 at 6:30 am
I check the Return Code, the Recordcount and I dump the Parameters collection:
Paging records returned=-1 This is rs.recordcount
RC: : No Return Code (no "return" in SP)
Parms:3: Number of Parms (correct)
0=RETURN_VALUE-><-3 Parm 0=Return Code (empty) 3=integer
11=@poolid->1<-3 Parm 1=@poolid= Integer value=1
02=@rid->0<-3 Parm 2=@rid = Integer value=0
Is there anything else I can check?
February 14, 2007 at 6:57 am
My starting point on these is always to use (classic ASP this)
on error resume next
...
if err.number 0 then response.write err.description
I'd be inclined to be more explicit on the final 'select' and try with just one of the columns to make sure nothing is fouling and preventing the rest of the output.
February 14, 2007 at 7:11 am
Tried both. Err.number=0 so there's no message. Changed the Select to return only the first column -- same results.
ANy idea why I'm still getting "(1 row(s) affected)" in QA when I run the SP even though I have SET NOCOUNT ON; in the SP?
February 14, 2007 at 7:16 am
The message above is from the
SELECT 'Return Value' = @return_value
in QA and has nothing to do with the actual execution of the SP. If I comment that out in QA and run the SP I get back "Command(s) completed successfully."
More mysterious...
February 14, 2007 at 7:43 am
Hi,
I noticed that in your original code you don't have the keyword RETURN. This is one of the sprocs templates I use frequently. Used for populating individual items in .NET. For populating a dataset to a datagrid or datalist you don't need the keywords OUTPUT;the SQL is SELECT field1, etc.. but still using the RETURN keyword
CREATE PROCEDURE Stored procedure name
(
@userid INT, -- INPUT PARAMETER
@UName VARCHAR(50) OUTPUT -- OUTPUT PARAMETER
)
AS
/***********************************************************************
************************************************************************
** Copyright Notice
**
** Procedure Name: Stored procedure name
** Description: Stored procedure definition **
**
** Return values:
** Input Params:
** Output Params:
** Author: <>
** Date: <>
************************************************************************
************************************************************************
** Change History
************************************************************************
************************************************************************
** Date: Author: Description:
** -------- --------
---------------------------------------
**
************************************************************************
********************************************************/
DECLARE @Error INT
SET NOCOUNT ON
BEGIN
-- Populates individual text items in asp.net OUTPUT keyword is required
SELECT @UName = uname,
FROM user_information_V WHERE loginID = @user-id
-- Populates a grid or datalist in asp.net OUTPUT keyword is not required
SELECT uname,fname,lname FROM user_information_V
END
RETURN
SET @Error = @@ERROR
IF @Error <> 0
BEGIN
RETURN @Error
END
RETURN @Error
These are two sprocs. Hope this helps
February 14, 2007 at 8:17 am
I added a RETURN at the end of my SP with no change. Thanks anyway!
February 14, 2007 at 3:36 pm
Is there a reason you have the semi-colon after SET NOCOUNT ON? If not, remove that and give it a shot. If that doesn't work, tell us how many recordsets ADO thinks it has after this call.
February 15, 2007 at 6:03 am
Removing the semi-colon didn't matter, but my code was depending on RecordCount to proceed. I changed it to just ignore RecordCount and read until EOF and I got back my records.
The RecordCount must be off because of the Cursor. Since I'm using:
There's no way to set the cursor attributes (that I know of). Displaying them yields:
I'm OK with the Lock Type unless it also affects RecordCount.
Anyone know how to set Cursor and Lock values in the above code usage??
February 15, 2007 at 9:51 am
The following code will set the cursor and lock types and allow correct access to the RecordCount and Return Code (Parameters(0)):
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply