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
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.
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.