Dim parameter As SqlParameter = Comment.InsertCommand.Parameters.Add("@Identity

Reaction

Member
Joined
Apr 29, 2007
Messages
13
Programming Experience
1-3
I put that up as my Thread title so I can get a quick response. Basically I have a line in my code to retrieve the ID generated when I insert an item into my Db


VB.NET:
' Create the InsertCommand.
Comment.InsertCommand = New SqlCommand("dbo.InsertComment", connection)
Comment.InsertCommand.CommandType = CommandType.StoredProcedure
' Add the parameter for the CategoryName. Specifying the
' ParameterDirection for an input parameter is not required.
Comment.InsertCommand.Parameters.Add("@Comment", SqlDbType.NVarChar, 15, "Comment")
' Add the SqlParameter to retrieve the new identity value.
' Specify the ParameterDirection as Output.
Dim parameter As SqlParameter = Comment.InsertCommand.Parameters.Add("@Identity", SqlDbType.Int, 0, "CommentID")
parameter.Direction = ParameterDirection.Output



How do I retrieve this ID and store it in a integer variable to use in other calculations?


Reaction


 
Back
Top