开发者

error '800a01b6': Object doesn't support this property or method: Object.Parameters.Add'

This is an extension to: Returning SCOPE_IDENTITY() using Adodb.Command

Trying to get SCOPE_IDENTITY() using ADO.Command from a SP but get an error when I run the Ado.Command.. Here is the code example:

The Stored Procedure:

CREATE PROCEDURE TESTSP
@LASTID int OUTPUT

AS
BEGIN
SET NOCOUNT ON;

INSERT INTO TABLE1 (VAL1,VAL2) VALUES (VAL1,VAL2)

SET @LASTID = SCOPE_IDENTITY()

The ADO Request:

set SQLCOMM = Server.CreateObject("ADODB.Command")
SQLCOMM.ActiveConnection = CONNSTRING
SQLCOMM.CommandText = TESTSP
SQLCOMM.CommandType = 1
SQLCOMM.CommandTimeout = 0
SQLCOMM.Prepared = true

LastIDParameter = SQLCOMM.CreateParameter("@LastID",3,2)
SQLCOMM.Parameters.Add(LastIDParameter) 

SQLCOMM.Execute()

INSERT_RETURNS_SCOPEID=LastIDParameter.Value

set SQLCOMM=Nothing

This is causing the error: LastIDParameter = SQLCOMM.CreatePar开发者_StackOverflow社区ameter("@LastID",3,2)


Your line:

SQLCOMM.CommandType = 1

should be instead:

SQLCOMM.CommandType = CommandType.StoredProcedure
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜