这是经典的 ASP 代码
Set objCommandSec = CreateObject("ADODB.Command")
With objCommandSec
Set .ActiveConnection = MyConn
.CommandType = adCmdStoredProc
.CommandText = "ReportsPDFInsert"
.CreateParameter "@StatsID", adInteger, adParamInput
.Parameters("@StatsID") = xStats_ID
.CreateParameter "@MemberID", adInteger, adParamInput
.Parameters("@MemberID") = xMemberID
.CreateParameter "@LanguageID", adInteger, adParamInput
.Parameters("@LanguageID") = 1 '1=EN
.CreateParameter "@PDFFilename", adVarWChar , adParamInput
.Parameters("@PDFFilename") = PDFFilename
.Execute
End With
这是存储过程代码
ALTER PROCEDURE [dbo].[ReportsPDFInsert]
-- Add the parameters for the stored procedure here
@StatsID INT
,@MemberID INT
,@LanguageID INT
,@PDFFilename NVARCHAR(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
INSERT INTO [dbo].[ReportsPDF]
([StatsID]
,MemberID
,[LanguageID]
,[PDFFilename]
,[DateCreated])
VALUES
(@StatsID
,@MemberID
,@LanguageID
,@PDFFilename
,GETDATE())
END
我得到错误
错误号:-2147217904
错误描述:过程“ReportsPDFInsert”需要参数“@StatsID”,但未提供该参数。
来源:Microsoft OLE DB Provider for SQL Server
如果我自己执行存储过程,那么它工作正常。我在其他页面中有类似的经典 asp 代码,也可以正常工作。是的,我确定 xStats_ID 确实有价值。我在 .Execute 之前打印,我看到了值。
请有人解释一下。谢谢