Getting stored procedure's return value with iBatis.NET

Posted by MikeWyatt on Stack Overflow See other posts from Stack Overflow or by MikeWyatt
Published on 2010-03-17T13:56:03Z Indexed on 2010/03/17 18:01 UTC
Read the original article Hit count: 697

How can I retrieve the return value of a stored procedure using iBatis.NET? The below code successfully calls the stored procedure, but the QueryForObject<int> call returns 0.

SqlMap

<procedure id="MyProc" parameterMap="MyProcParameters" resultClass="int">
    MyProc
</procedure>

<parameterMap id="MyProcParameters">
    <parameter property="num"/>
</parameterMap>

C# code

public int RunMyProc( string num )
{
    return QueryForObject < int > ( "MyProc", new Hashtable { { "num", num } } );
}

Stored Procedure

create procedure MyProc
    @num nvarchar(512)
as
begin
    return convert(int, @num)
end

FYI, I'm using iBatis 1.6.1.0, .NET 3.5, and SQL Server 2008.

© Stack Overflow or respective owner

Related posts about ibatis.net

Related posts about stored-procedures