I am trying to update some old functionality. There is a stored procedure that has one input parameter and two output parameters. I am getting the following error when I try to execute the code:
Microsoft OLE DB Provider for ODBC Drivers error '80040e21' Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. /student.asp, line 30
Stored Procedure:
ALTER PROCEDURE [Api].[GetKeyByAuthId]
@AuthenticationId uniqueidentifier
, @Key int = NULL OUTPUT
, @type varchar(25) = NULL OUTPUT
Direct call works great:
USE [Development]
GO
DECLARE @return_value int,
@Key int,
@type varchar(25)
EXEC @return_value = [Api].[GetKeyByAuthId]
@AuthenticationId = '0550F579-DBDA-4C41-82B3-453841A6232E',
@Key = @Key OUTPUT,
@type = @type OUTPUT
SELECT @Key as N'@Key',
@type as N'@type'
SELECT 'Return Value' = @return_value
GO
Authentication Id is unique identifier and is received via query string on the page. Here is my code, line 30 is cmd.Execute:
var cmd = Server.CreateObject("ADODB.Command");
cmd.CommandText = "Api.GetKeyByAuthId";
cmd.CommandType = 4; // Stored procedure
var p = cmd.Parameters;
p.Append(cmd.CreateParameter("@AuthenticationId", 72, 1));
p.Append(cmd.CreateParameter("@Key", 3, 2, 9));
p.Append(cmd.CreateParameter("@type", 200, 2, 25));
cmd("@AuthenticationId") = aid;
cmd.ActiveConnection = Conn;
cmd.Execute();
Key = cmd.Parameters("@Key");
type = cmd.Parameters("@type");