Invalid parameter type between C# and Oracle

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pacosino
    New Member
    • May 2011
    • 1

    Invalid parameter type between C# and Oracle

    Hello,
    I have a strange situation with something and maybe someone here can help me. I have a function in Oracle that returns a sequence number. When i try to get that value in C# by a parameter it always tells me that the parameter type is invalid. A sample value of that returned value is 115545. If indeed this error is correct then what is the correspondent in ODBCType for this value? If it isn't correct then what is the problem?

    Oracle function is:
    Code:
    FUNCTION Get_Next_Message_Id__ RETURN NUMBER
    IS
       temp_ NUMBER;
       CURSOR get_in_message_id_seq IS
          SELECT in_message_id_seq.NEXTVAL
          FROM   dual;
    BEGIN
       General_SYS.Init_Method(lu_name_, 'IN_MESSAGE_API', 'Get_Next_Message_Id__', TRUE);
       OPEN get_in_message_id_seq;
       FETCH get_in_message_id_seq INTO temp_;
       CLOSE  get_in_message_id_seq;
       RETURN(temp_);
    END Get_Next_Message_Id__;
    C# Code is:
    Code:
    OdbcConnection myConnection = new OdbcConnection(ODBC_CLass.ifsconnectionstring);
                OdbcParameter next_id = new OdbcParameter();
                next_id.Direction = ParameterDirection.Output;
                myConnection.Open();
                OdbcCommand command = new OdbcCommand("{? = call ifsapp.in_message_api.Get_Next_Message_Id__}", myConnection);
                command.CommandType = CommandType.StoredProcedure;
                next_id = command.Parameters.Add("temp_", OdbcType.Int);
                int k = command.ExecuteNonQuery();
                MessageBox.Show("next_id: " + next_id.Value);
Working...