Welcome to WebmasterWorld Guest from 54.242.115.55

Forum Moderators: ocean10000

Message Too Old, No Replies

VB Stored Procedure quick question

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0


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,

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

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:864
votes: 3


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.

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 10, 2008
posts:1130
votes: 0


Thanks,