存储过程有输出参数,在c#中用nhibernate调用存储过程时,
如何才能获取到一个结果集和这个输出参数呢?
首先创建一个存储过程
create proc test
@int int output
as
begin
set @int=9;
end
写一个测试方法
public string test()
{
ISession session = NHibernateHelper.GetOcextSession();
IDbCommand com=session.Connection.CreateCommand();
com.CommandType = CommandType.StoredProcedure;
com.CommandText = "test";
IDbDataParameter parme = com.CreateParameter();
parme.DbType = DbType.Int32;
parme.Direction = ParameterDirection.Output;
parme.ParameterName = "int";
parme.Size =10;
com.Parameters.Add(parme);
com.ExecuteNonQuery();
return parme.Value.ToString();
}
结果为: