Kerry is right on the money. It works well with stored procedures too. In the
example I give below, the stored procedure returns the new identity value.
However the example will retrieve whatever return value is coded into the
stored procedure, so it's utility isn't just for new identies.
cmd.CommandText = ""DECLARE @RETURN int; EXEC @RETURN = CustInsert 'John
Smith', '3/15/1959'; SELECT @RETURN [RETURN]"
It's actually a generic wrapper that looks like -
"DECLARE @RETURN int; EXEC @RETURN = " & s & "; SELECT @RETURN [RETURN]"
where s is the procedure with parameters built outside the function.
If you are writing tons of DB code, you don't want to have to deal with
parameter objects, since they don't offer any performance advantage anyway.