Forums
This topic is locked
put retrieve auto number in a session
Posted 13 May 2006 21:12:09
1
has voted
13 May 2006 21:12:09 DOR Webmaster posted:
i have a stored procedure that works fine at inserting a record and retrieving the ID..here it is:CREATE PROC WPRO_FOLLOW_UP_INSERT_RETRIEVE
(
@STUDYID INT,
@USERID INT,
@EDITEDBY INT,
@RETURNID INT OUTPUT
)
AS
INSERT INTO dbo.WPARTICIPANTS_FU (STUDYID,ENTERED_BY,EDITED_BY)
VALUES (@StudyID,@USERID,@EDITEDBY )
SET @RETURNID = SCOPE_IDENTITY()
RETURN
GO
here is the ASP VB code i am trying to turn the returned ID into a session variable..but it does not seem to work...
any help would be greatly appreciated
<%
set WPRO_FOLLOW_UP_INSERT_RETRIEVE = Server.CreateObject("ADODB.Command"
WPRO_FOLLOW_UP_INSERT_RETRIEVE.ActiveConnection = MM_tosql_STRING
WPRO_FOLLOW_UP_INSERT_RETRIEVE.CommandText = "dbo.WPRO_FOLLOW_UP_INSERT_RETRIEVE"
WPRO_FOLLOW_UP_INSERT_RETRIEVE.Parameters.Append WPRO_FOLLOW_UP_INSERT_RETRIEVE.CreateParameter("@RETURN_VALUE", 3, 4)
WPRO_FOLLOW_UP_INSERT_RETRIEVE.Parameters.Append WPRO_FOLLOW_UP_INSERT_RETRIEVE.CreateParameter("@STUDYID", 3, 1,4,WPRO_FOLLOW_UP_INSERT_RETRIEVE__STUDYID)
WPRO_FOLLOW_UP_INSERT_RETRIEVE.Parameters.Append WPRO_FOLLOW_UP_INSERT_RETRIEVE.CreateParameter("@USERID", 3, 1,4,WPRO_FOLLOW_UP_INSERT_RETRIEVE__USERID)
WPRO_FOLLOW_UP_INSERT_RETRIEVE.Parameters.Append WPRO_FOLLOW_UP_INSERT_RETRIEVE.CreateParameter("@EDITEDBY", 3, 1,4,WPRO_FOLLOW_UP_INSERT_RETRIEVE__EDITEDBY)
WPRO_FOLLOW_UP_INSERT_RETRIEVE.Parameters.Append WPRO_FOLLOW_UP_INSERT_RETRIEVE.CreateParameter("@RETURNID", 3, 2)
WPRO_FOLLOW_UP_INSERT_RETRIEVE.CommandType = 4
WPRO_FOLLOW_UP_INSERT_RETRIEVE.CommandTimeout = 0
WPRO_FOLLOW_UP_INSERT_RETRIEVE.Prepared = true
set FOLLOW_UP_INSERT_RETRIEVE = WPRO_FOLLOW_UP_INSERT_RETRIEVE.Execute
FOLLOW_UP_INSERT_RETRIEVE_numRows = 0
Session("FUID" = WPRO_FOLLOW_UP_INSERT_RETRIEVE.Parameters.Item("@RETURNID".Value
%>