假設有存儲過程如下:
CREATE PRoc sp_uptmp @tmpName varchar(
as
Begin TRAN
insert into t_template values(@tmpName
COMMIT
return isnull(@@identity
GO
在 裡面獲取返回值的方法為(c#):
SqlConnection dbconn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand(
cmd
SqlParameter tmpName = cmd
SqlParameter srcPos = _cmd
SqlParameter rtnval = cmd
tmpName
srcPos
rtnval
tmpName
srcPos
dbconn
cmd
dbconn
tmpid = (int)rtnval
From:http://tw.wingwit.com/Article/program/net/201311/13773.html