English 中文(简体)
用2008年储存的SQ服务器添加的“古典”是指我有太多的参数,或者没有具体规定参数。
原标题:Classic asp insert using SQL Server 2008 stored proc says I either have too many parameters, or the parameter was not specified

从我做过任何典型的算术工作以来,时间已很长,但最近有人要求他接受另一个人正在做的只是我的项目。

该网址在后端有2008年服务器数据库,我需要添加一个记录,并检索作为直径的自动识别栏。

我的《手法》载于这里......

Call fncOpenData()
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = oConn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "usp_ins_MyRecord"
cmd.Parameters.Refresh
cmd.Parameters.Append cmd.CreateParameter("@MyValue", adVarChar, adParamInput, 10)
cmd.Parameters("@MyValue") = Request.Form("MyValue")
cmd.Execute

而我所储存的程序是用此法典制定的。

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE usp_ins_MyRecord
    @MyValue    varchar(10)
AS
BEGIN
    INSERT INTO [MyRecords]
    (
        [MyValue]
    )
    VALUES
    (
        @MyValue
    )
END
GO

现在,当我上页时,我有以下错误......

“Microsoft OLE DB 为ODBC司机提供错误 80040e14

[Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 或function usp_ins_MyRecord has too many arguments specified.

/MyPage.asp, Line ...”

如果我去掉这一条线,

cmd.Parameters.Refresh

I get the following error...

“Microsoft OLE DB 为ODBC司机提供错误 80040e14

[Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 或function usp_ins_MyRecord expects parameter @MyValue , which was not supplied.

/MyPage.asp, Line ...”

Erm, yes it was?!

如果我以任何其他方式改变我的代码,增加参数,例如

cmd.Parameters.Append cmd.CreateParameter("@MyValue", adVarChar, adParamInput, 10, Request.Form("MyValue")

myValue = Request.Form("MyValue")
Set param = cmd.CreateParameter("@MyValue", advarchar, adParamInput, 10)
cmd.Parameters.Append param
param.Value = myValue

I get the same err或as before, stating the parameter wasn t specified?

我知道这一技术是过时的,我确实希望能使用。 净额是我必须使用的,但我却把我的头发拉到这里,不快。

Can anyone see what s wrong, 或explain why I m having trouble getting ASP to use SQL Server 2008 stored procs?

感谢。

最佳回答

亚洲开发银行参数收集的Refresh方法自动增加了从储存程序到你的指挥的参数。

要么使用Refresh,要么单独使用Paraile。

如果供应商允许,你可以采用Refresh方法,将参数收集工作集中起来。 事实上,如果你试图利用这一收集方法,而这种收集是空的,或者在你第一次要求重新收监之前,情报和安全局将自动要求Refresh为收集资料而登记。 提供参数的效率更高,而不是要求供应商提供这种信息。 (你可以做些什么来减少向供应商发出的呼吁,将会提高业绩。) 你可以增加使用附录财产的参数物体。

Ref: http://www.devguru.com/technologies/ado/quickref/command_parameterscollection.html

<>>>>>

在你建立自己的参数时,你也应当设法删除“@”的字样。

cmd.Parameters.Append cmd.CreateParameter("MyValue", adVarChar, adParamInput, 10, Request.Form("MyValue"))
问题回答

I was in an identical situation in almost every way...including why I was working with Classic ASP and the flipping between error messages. The accepted response was helpful in deciding not to use "cmd.Parameters.Refresh"

OK so why was I getting the "expects parameter" error when it clearly was there? In my case...the line where I was creating the parameter was missing a part for the CreateParameter call:

I had:

<>strong>cmd.Para下限,Append厘米d.CreatePara下限("@PoNum”,3,1,PONum) adInteger = 3, adInputParam = 1

Incorrectly I was thinking I didn t need to specify a size for an integer. Size zero seems to work though... So things began to work correctly when I put zero in for the size.

cmd.Paramiles.Append厘米d.CreatePara amount("@PoNum”, 3, 1, 0,PONum) adInteger = 3, adInputParam = 1

Sorry I wasn t using the adxxxxxcies... 我在此继承了某些法典,我 could不易转换成使用这些常数。 ......因为所有这些都通过该法典,有些是作为变数使用的必要常数。 我只能等回来。

Try a simpler way of executing stored procedure within asp classic code using ADODB.Connection rather than ADODB.Command...

Set con = Server.CreateObject( "ADODB.Connection" )
con.Open oConn

sql = "exec usp_ins_MyRecord @myValue= " & somevalue & " "
Set RS = con.execute(sql)

之后,在储存程序中添加一条线,以恢复最近添加的记录的特性。

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE usp_ins_MyRecord
    @MyValue    varchar(10)
AS
BEGIN
    INSERT INTO [MyRecords]
    (
        [MyValue]
    )
    VALUES
    (
        @MyValue
    )

SELECT @@identity AS recordid
END
GO

然后,你可以从记录中取回。

IF NOT RS.EOF THEN
  myRecordid = RS("recordid")
END IF




相关问题
Performance impact of indexed view in MS SQL Server 2008

Does anyone have experience with using indexed view in MS SQL Server 2008? I am trying to find out how does indexed view affect performance of insert / update statements, that are adding / updating ...

Lock Escalation - What s happening here?

While altering a table (removing a column) in SQL Server 2008, I clicked the Generate Change Script button and I noticed that the change script it generated drops the column, says "go" and then runs ...

Round to nearest 5 in SQL Server

I have a Money column in my SQL Server 2008 table. In my below query how can I round it to nearest 5$ select FineAmount from tickets Thanks

热门标签