Using ASP with SQL Server 7.
It seems that an OUTPUT parameter value cannot be obtained in the same call with a recordset. Is this true or am I missing something?
Here is the stored procedure.
Here is the ASP script that gets the recordset and the OUTPUT parameter value.
This leads to undefined value for userCount. But executing the command without a recordset like this
returns a value for userCount.
Is this the way the Parameter object is supposed to work?
Thanks,
Richard
It seems that an OUTPUT parameter value cannot be obtained in the same call with a recordset. Is this true or am I missing something?
Here is the stored procedure.
Code:
CREATE PROCEDURE [proc_create_users_list_and_count] (
@how_many INT OUTPUT
)
AS
SELECT user_id,
first_name,
last_name,
user_or_admin
FROM users
SELECT @how_many = COUNT(*) FROM users
Here is the ASP script that gets the recordset and the OUTPUT parameter value.
Code:
var cmdUsers = Server.createObject("ADODB.Command");
cmdUsers.activeConnection = conn; //conn is defined elsewhere.
//Retrieve number of users with an OUTPUT parameter.
cmdUsers.commandText = "{CALL proc_create_users_list_and_count(?)}";
var adInteger = 3; //type
var sizeBytes = 4; //size
var adParamOutput = 2; //direction
var parmUserCount = Server.createObject("ADODB.Parameter");
parmUserCount.Type = adInteger;
parmUserCount.Direction = adParamOutput;
parmUserCount.Size = sizeBytes;
cmdUsers.parameters.Append(parmUserCount);
rsUsers = cmdUsers.execute();
var userCount = parmUserCount.value;
This leads to undefined value for userCount. But executing the command without a recordset like this
Code:
cmdUsers.execute();
Is this the way the Parameter object is supposed to work?
Thanks,
Richard