【发布时间】:2011-08-30 17:43:45
【问题描述】:
我有一个插入语句(存储过程),它在插入后返回 SCOPE_IDENTITY(),但是,我试图弄清楚在经典 ASP 中使用ADODB.Command 请求后如何返回它。
SP 在最后包含了这个:
SET @LastID = SCOPE_IDENTITY() -- @LastID is an INT OUTPUT param.
这是在经典 ASP 代码中处理插入查询时调用的内容:
set SQLCOMM = Server.CreateObject("ADODB.Command")
SQLCOMM.ActiveConnection = CONNSTRING
SQLCOMM.CommandText = "Insert_SP_Returns_ScopeID"
SQLCOMM.CommandType = 1
SQLCOMM.CommandTimeout = 0
SQLCOMM.Prepared = true
LastIDParameter = SQLCOMM.CreateParameter("@LastID",adInteger,adParamOutput)
SQLCOMM.Parameters.Add(LastIDParameter)
SQLCOMM.Execute()
LastID = LastIDParameter.Value
set SQLCOMM=Nothing
在我set SQLCOMM=Nothing之前我会做这样的事情吗?
NewID = SQLCOMM("LastID").Value
或者...可以从Adodb.Recordset 代替ADODB.Command 执行插入/更新存储过程吗?
The example above gives the following error message:
ADODB.Command error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range,
or are in conflict with one another.
由于这行代码正在返回错误:
LastIDParameter = SQLCOMM.CreateParameter("@LastID",adInteger,adParamOutput)
【问题讨论】:
标签: sql-server tsql ado