Stored procedures 什么';经典ASP StoredProcess insert语句中的错误
下面是经典的ASP代码Stored procedures 什么';经典ASP StoredProcess insert语句中的错误,stored-procedures,asp-classic,Stored Procedures,Asp Classic,下面是经典的ASP代码 Set objCommandSec = CreateObject("ADODB.Command") With objCommandSec Set .ActiveConnection = MyConn .CommandType = adCmdStoredProc .CommandText = "ReportsPDFInsert" .CreateParameter
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”
来源:用于SQL Server的Microsoft OLE DB提供程序
如果我执行存储过程本身,那么它工作正常。我在另一个页面中有类似的经典asp代码,而且效果也不错。是的,我确保xStats_ID确实有值。我在.Execute之前打印了,我看到了值
请有人照点光。谢谢尝试使用如下方式显式附加参数:
cmd.Parameters.Append cmd.CreateParameter("@StatsID",adInteger, adParamInput,xStats_ID)
而不是。参数(“”
下面是另一篇可能有帮助的帖子:
尝试使用如下方式显式附加参数:
cmd.Parameters.Append cmd.CreateParameter("@StatsID",adInteger, adParamInput,xStats_ID)
而不是。参数(“”
下面是另一篇可能有帮助的帖子:
尝试删除参数名称中的“@”。尝试删除参数名称中的“@”。直到今天,我才发现问题所在 我还没有包括adovbs.inc文件以使常量正常工作 我不知道它为什么会抛出其他错误消息
离开传统ASP的好理由[只有在我的老板听了的情况下]直到今天,我才知道问题出在哪里 我还没有包括adovbs.inc文件以使常量正常工作 我不知道它为什么会抛出其他错误消息
离开经典ASP的好理由[只有在我的老板听的情况下]不,我甚至尝试了大小参数为0的相同错误消息。虽然这没有解决OP的具体问题,但这是一个很好的建议。需要注意的是,它本身只创建一个
参数
对象,而不将其附加到参数
集合中。原始代码工作的原因是ADO正在查询数据库以自动填充集合(请参阅)。OP中的CreateParameter
调用是不必要的。不,同样的错误消息我甚至尝试了大小参数0。虽然这没有解决OP的具体问题,但这是一个很好的建议。需要注意的是,它本身只创建一个参数
对象,而不将其附加到参数
集合中。原始代码工作的原因是ADO正在查询数据库以自动填充集合(请参阅)。OP中的CreateParameter
调用是不必要的。MyConn
是连接字符串还是连接对象?试试.ActiveConnection=MyConn
MyConn是连接字符串还是连接对象?尝试.ActiveConnection=MyConn