[Mono-devel-list] OdbcCommand doesn't return out parameter from stored procedure

Spatar Sergey spatar at mail.nnov.ru
Tue May 18 02:13:06 EDT 2004


Hello,
I've got the following problem. Please help.

When OdbcCommand executes stored procedure its out parameters remain
unchanged, i.e. out values are not put to binded variables


Following code reproduces the problem:
--cut--
OdbcConnection m_dbConnection = null;
OdbcCommand command = null;
try
{
    // Open connection with Oracle database
    m_dbConnection = new OdbcConnection("DSN=ORACLE;Server=UVOIPDB;
Uid=voip;Pwd=1" );
    m_dbConnection.Open();

    // Create ODBC command
    command = m_dbConnection.CreateCommand();
    command.CommandText = "{call pkg_auth_dev.ip_authentic7 (?)}";
    command.CommandType = CommandType.StoredProcedure;

    // Create out parameter
    OdbcParameter param = new OdbcParameter("p_login", OdbcType.VarChar, 20 
);
    if( param == null ) {
        Console.WriteLine( "if( param == null )" );
    }
    param.Direction = ParameterDirection.Output;
    param.Value="init_value";
    // Add parameter to command
    command.Parameters.Add( param );

    Console.WriteLine( "ExecuteNonQuery...\n" );
    // Execute command
    command.ExecuteNonQuery();
    Console.WriteLine( "OK" );
    // Print parameter's value
    Console.WriteLine("Result: " + (string)(command.Parameters[ "p_login" ]
.Value));

}
catch(OdbcException e)
{
    Console.WriteLine( e.Message );
}
finally
{
    command.Dispose();
    m_dbConnection.Dispose();
}
--cut--
No exceptions happened while executing this code, but console output is
--cut--
ExecuteNonQuery
OK
Result: init_value
--cut--


How often does this happen? 
Always


Additional Information:
I used EasySoft unixODBC-2.2.3-6 with odbc-oracle-1.3.1 driver
  

-- 
Best regards,
Sergey Spatar





More information about the Mono-devel-list mailing list