How to retrieve the IDENTITY from an inserted record.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following example works, but the retrival of the returned identity does not work

'Set Command Object Propertie
objCommand.ActiveConnection = GV_objConnectio
objCommand.CommandText = "DAO.RCCBABY_Add_Test
objCommand.CommandType = ADODB.CommandTypeEnum.adCmdStoredPro

'Set The Parameter
objCommand.Parameters.Append(objCommand.CreateParameter("TestKey", ADODB.DataTypeEnum.adInteger, ADODB.ParameterDirectionEnum.adParamReturnValue)
objCommand.Parameters.Append(objCommand.CreateParameter("Test1", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 10, TextBox1.Text)
objCommand.Parameters.Append(objCommand.CreateParameter("Test2", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 10, TextBox2.Text)
objCommand.Parameters.Append(objCommand.CreateParameter("Test3", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 10, TextBox3.Text)

'Execute the comman
objCommand.Execute(

RetrievedData = objCommand.Parameters("TestKey").Value -----> THIS INSTRUCTIONS DOES NOT WORK, RETURN NOTHIN

This is the stored procedure

CREATE PROCEDURE ADO.RCCBABY_Add_Test (@Test1 VarChar (10)
@Test2 VarChar (10)
@Test3 VarChar (10)) A
begin transactio
begi
INSERT INTO Tes
(Test1
Test2
Test3
VALUE
(@Test1
@Test2
@Test3
en
commi

return @@identity -----> NOTE THIS IS RETURNNING THE IDENTIT
GO
 
Back
Top