1
我已經在SQL Server 2008 R2數據庫與可選的輸入參數的存儲過程和一個像這樣的輸出參數:使用可選的輸入參數,ADODB是否在輸出參數上失敗?
CREATE PROCEDURE [dbo].[spCreateTicket]
(
@TrackingCode varchar(25),
@EmailAddress varchar(250) = null,
@Ticket varchar(1000),
@UserID int,
@TicketID int output
)
AS
SET NOCOUNT ON
INSERT INTO dbTicket (TrackingCode, EmailAddress, Ticket, UserID)
SELECT
@TrackingCode, @EmailAddress, @Ticket, @UserID
SELECT @TicketID = SCOPE_IDENTITY()
RETURN @TicketID
當我在SSMS調用存儲過程沒有可選參數正常工作:
DECLARE @TicketID int
EXEC [dbo].[spCreateTicket]
@TrackingCode = 'xOCDUv289u403k5h24s5869vK',
@Ticket = 'Something broke!',
@UserID = 64307,
@TicketID = @TicketID OUTPUT
但是,當我試圖通過ADODB在ASP經典是這樣一回事:
SET cmd = Server.CreateObject ("ADODB.Command")
cmd.ActiveConnection = HelpDeskConnection
cmd.CommandText = "spCreateTicket"
cmd.CommandType = adCmdStoredProc
cmd.Parameters.Append cmd.CreateParameter ("@TrackingCode",adVarChar,adParamInput,25,RandomString(25))
cmd.Parameters.Append cmd.CreateParameter ("@Ticket",adVarChar,adParamInput,1000,Ticket)
cmd.Parameters.Append cmd.CreateParameter ("@UserID",adInteger,adParamInput, ,Session("UserID"))
cmd.Parameters.Append cmd.CreateParameter ("@TicketID",adInteger,adParamOutput)
cmd.Execute
TicketID = cmd.Parameters("@TicketID")
它什麼也不做,@TicketID
留下Empty
,並且ADODB.Connection包含此NativeError 8162:
「的正式參數\」 @用戶名\「未聲明爲OUTPUT參數 ,但在請求的輸出傳遞的實際參數」
我使用ADODB來調用沒有可選參數的存儲過程。這是ADODB中的一個已知缺陷,還是我需要做一些特殊的事情來讓它在有輸出參數的情況下工作?