首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# 接受存储过程返回值 跟 output 返回值

2012-07-30 
C# 接受存储过程返回值 和 output 返回值 try{int iCnt -1int iTest -1SqlParameter[] para {new

C# 接受存储过程返回值 和 output 返回值

 try        {            int iCnt = -1;            int iTest = -1;            SqlParameter[] para = {                                 new SqlParameter("@col1",10),                                new SqlParameter("@col2",'Z'),                                new SqlParameter("@cnt",iCnt),                                new SqlParameter("@test",iTest)                              };            para[2].Direction = ParameterDirection.Output;//这里接受的是output的值            para[3].Direction = ParameterDirection.ReturnValue;//这里接收的是return 的值            SqlHelper.ExecuteNonQuery(sConn, CommandType.StoredProcedure, "p_tab", para);            string str1 = para[2].Value.ToString();            string str2 = para[3].Value.ToString();        }        catch (Exception ex)        {            throw ex;        }


 

 ALTER proc [dbo].[p_tab]@col1 int ,@col2 varchar(20),@cnt int outputasbegin insert into Tab values(@col1,@col2) select @cnt= COUNT(1) from Tab declare @test int set @test=55 return @testend


 

热点排行