--存储过程
ALTER PROCEDURE testTrans1
(@rtn INT OUTPUT)
AS
BEGIN TRAN
IF(2<3)
BEGIN
ROLLBACK TRAN
SET @rtn=0;
RETURN @rtn;
END
commit tran
SET @rtn=1;
RETURN @rtn;
DECLARE @rtn INT
EXEC testTrans1 @rtn OUT
PRINT @rtn
------------------------------------------------------------
c#代码
SqlParameter[] parameters = {
new SqlParameter("@rtn",SqlDbType.Int)
};
parameters[0].Direction = ParameterDirection.Output;
DalBase.ExecuteNonQuery(CommandType.StoredProcedure, "testTrans1", parameters);
int nRtnNum = 0;
nRtnNum = Convert.ToInt32(parameters[0].Value);
时间: 2024-10-26 03:24:47