I'm making an app to add test questions to a SQL DB. I'm planning on using a Stored procedure to insert the question and then would like to return the Identity so I can use that to do the inserts for the answers into the Answers table. So far I have this as the stored procedure.
and in the form I'm using this codeCode:CREATE PROCEDURE sp_AddQuestion ( @question AS VARCHAR (8000), @Identity AS INT ) AS INSERT INTO Questions(questions) values(@question) RETURN SELECT @@IDENTITY as 'Identity' GOWhen I try to run this I'm getting the following error on the execute line.VB Code:
Private Sub cmdInsert_Click() Dim objCmd As ADODB.Command Dim rs As ADODB.Recordset Set objCmd = New ADODB.Command With objCmd Set .ActiveConnection = Cn .CommandType = adCmdStoredProc .CommandText = "sp_AddQuestion" .Parameters.Append .CreateParameter("@question", adVarChar, adParamInput, 300, "Test question Input") .Parameters.Append .CreateParameter("@Identity", adInteger, adParamOutput, 4) Set rs = .Execute MsgBox rs.Fields(0) End With End Sub
What does this error mean and how can I return the id of the last record entered?Formal parameter ‘@Identity’ was defined as OUTPUT but the actual parameter not declared OUTPUT.




Reply With Quote