Rvalue of a stored procedure using C#



Hi all,
I tried to get the return value of a stored procedure in Ado.Net C# program
without sucess.
Have somebody any idea ?
Regards,
Gerard

Here is my code:

using System.Data.Odbc;
//...
OdbcConnection dbConn = null;
try
{
dbConn = new OdbcConnection ( "DRIVER={SQL
Server};SERVER=XXXX;DATABASE=tempdb;UID=XXXX;PWD=YYYY;WorkstationID=XXXX;ApplicationName=TEST;" );
OdbcCommand dbCmd = dbConn.CreateCommand();
dbCmd.Parameters.Add("@RETVAL",OdbcType.Int).Direction =
System.Data.ParameterDirection.ReturnValue;
dbCmd.CommandText = "pAdd 2,8";
dbConn.Open();
dbCmd.ExecuteNonQuery();
System.Console.WriteLine( "Return: " +
dbCmd.Parameters[0].Value.ToString());
System.Console.WriteLine( "Return: " + dbCmd.Parameters[0].ToString()); //
--> @RETVAL
System.Console.WriteLine( "Return: " + dbCmd.Parameters[0].Value);
System.Console.WriteLine( "Return: " + dbCmd.Parameters["@RETVAL"].Value);
}
catch(OdbcException exp)
{
System.Console.WriteLine("OdbcException exception catched\r\n"+exp.Message);
}
catch(Exception exp)
{
System.Console.WriteLine("Exception catched\r\n"+exp.Message);
}
finally
{

if ( dbConn != null )
{
dbConn.Close();
dbConn = null;
}
}

.



Relevant Pages

  • Re: Return value of a stored procedure using C#.
    ... Regards, ... Gerard ... >> I tried to get the return value of a stored procedure in Ado.Net C# ... >> catch(OdbcException exp) ...
    (microsoft.public.data.odbc)
  • Re: Rvalue of a stored procedure using C#
    ... I believe you need to set the command type to StoredProcedure like ... Regards, ... > catch(OdbcException exp) ...
    (microsoft.public.data.odbc)
  • emu10k1 broken
    ... Exp $ ... Regards, ... Sperber ... To unsubscribe, ...
    (freebsd-current)
  • Re: note 1
    ... If you were *really* interested in math, you would have a look at the *complete* solution I gave you a few ... conjugate, i.e exists h such that h o k o h^= exp)... ... you need to find k with * the same* fixed points as exp ... ...
    (sci.math)
  • Re: induced map
    ... There is exponential map Lie-> G. ... f |-> exp o f ... Best regards, ... Jose Carlos Santos ...
    (sci.math)

Loading