Forum Moderators: open

Message Too Old, No Replies

VB Stored Procedure quick question

         

andrewsmd

7:59 pm on Aug 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a stored procedure that does some things. On the last line it returns the scope identity like this

RETURN SCOPE_IDENTITY()

END

I execute the command like this

myConn.Open()
insertCommand.ExecuteNonQuery()
Catch ex As Exception
output.Text = "<span style='color:red;'>There was an error in adding the business.<br>" & _
"Please contact the system administrator if the problem persists. "
Finally
myConn.Close()
End Try

What my question is, is how do I assign that returned value to a variable. I need to call another stored procedure and pass in that returned identity. Thanks,

Ocean10000

12:23 am on Aug 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



comm.CommandText = "storedprocedure";
paramReturn = comm.CreateParameter();
paramReturn.ParameterName = "@Returned_Value";
paramReturn.DbType = DbType.Int32;
paramReturn.Direction = ParameterDirection.ReturnValue;
comm.Parameters.Add(paramReturn);

comm.ExecuteNonQuery();

now

paramReturn.Value will equal Your Identity Scope if any returned.

andrewsmd

3:30 am on Aug 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks,