tags:

views:

77

answers:

2

This is ADO in classic ASP.

I have a stored procedure with a parameter @IsNew of type int.

I can call it via SQL:

EXEC    [dbo].[SearchVehicles]
 @WebsiteName = N'AMSVans',
 @SortOrder = N'Year DESC,Status ASC',
 @Statuses = N'Unsold',
 @IsNew = 1

And the return sets are exactly as expected.

However, when I attempt to use it in my web page:

cmd.CommandText = "AMSVans.dbo.SearchVehicles"
cmd.CommandType = adCmdStoredProc

cmd.Parameters.Append cmd.CreateParameter("@WebsiteName", adVarChar, , 75, "AMSVans")
cmd.Parameters.Append cmd.CreateParameter("@SortOrder", adVarChar, , 500, "Year DESC,Status ASC," + SortMethod)
cmd.Parameters.Append cmd.CreateParameter("@Statuses", adVarChar, , 500, Statuses)
cmd.Parameters.Append cmd.CreateParameter("@IsNew", adInteger, , 4,1)
cmd.Parameters.Append cmd.CreateParameter("@Categories", adVarChar, , 500, "AMS Vans")

Set r = cmd.Execute

I get back nothing. Nada. Zilch.

I'm not even sure where to begin debugging this one :-/

Update RE "Set nocount on":

Interestingly, if I turn it off (ie, comment out that line), I get this error:

ADODB.Recordset error '800a0e78' 
Operation is not allowed when the object is closed. 
/pages/inventory/main.asp, line 109

The line in question (r is the recordset):

if not (r.EOF and r.EOF) then invFound = true
A: 

If your stored procedure can produce multiple result sets (including intermediate results that aren't intended for return) try setting nocount on at the beginning of the proc. Multiple results can cause problems for ado recordsets.

e.g.

Set NoCount On

Also, if that doesn't work, and you have changed the proc recently try running it from your page with different parameters so that you aren't getting a cached result.

Edit

I notice you are specifying a length for the int parameter, that is only necessary for variable length types, and would normally default to 0, try omitting it.

cmsjr
Its already there!
Matt
Interestingly, if I turn it off (ie, comment out that line), I get this error:ADODB.Recordset error '800a0e78'Operation is not allowed when the object is closed./pages/inventory/main.asp, line 109 The line in question (r is the recordset):if not (r.EOF and r.BOF) then invFound = true
Matt
Worth noting that changing the parameters doesn't change a thing, and that commenting out the "@IsNew" parameter works fine.
Matt
Omitting the length didn't change anything. (Thanks for you help so far btw)
Matt
thanks for *your* help
Matt
No problem, I know how frustrating it is to get one set of results from the query UI and another set from the application. Is there any way you could post the beginning of the stored proc declaration? Not the logic or anything, just the parameter definitions and whatnot.
cmsjr
A: 

I realize now that this would have been obvious to everyone if I had thought it relevant to say that the procedure has about 20 parameters, and since @IsNew was the last one, and the others were first - well, lets just say that adding default valued parameters for the ones in between made all the difference.

Matt
That's a characteristic of the provider, it interprets all the parameters positionally, regardless of the name.
cmsjr
Wish I had known that earlier - oh well, SQL traces to the rescue.
Matt