call from c # to a stored oracle procedure, if it works with one provider and not with another

1

who helps me with this problem, had a system in .net 1.1 (VS2003) that was connected to the provider Provider=MSDAORA.1 , all this ran in a WS2003 to perfection, it was decided to migrate this solution to VS2008 and run about WS2012R2, since this Windows does not have x86 I can not use this provider anymore so we change the connection string to use is provider Provider=ORAOLEDB.ORACLE , now we do not find it in tests and an SP is called in the following way:

        initializar_conn()

        comando = New OleDbCommand("BI.BI_Obtiene_ComFir_Trx", conn)
        comando.CommandType = CommandType.StoredProcedure

        Dim p_cod_ope As OleDbParameter = comando.Parameters.Add("pCodOpe", OleDbType.VarChar, 5)
        p_cod_ope.Direction = ParameterDirection.Input
        p_cod_ope.Value = CodOpe 'Codigo Operacion

        Dim p_trx As OleDbParameter = comando.Parameters.Add("pCodTrx", OleDbType.VarChar, 20)
        p_trx.Direction = ParameterDirection.Input
        p_trx.Value = CodTrx 'Codigo Transaccion

        Dim p_confir As OleDbParameter = comando.Parameters.Add("pConFir", OleDbType.VarChar, 50)
        p_confir.Direction = ParameterDirection.Output

        comando.ExecuteNonQuery()

        vConFir = Convert.ToString(p_confir.Value).Trim

The point is that with the old provider, the p_confirm.value returned the data returned by the sp, but with the new provider I simply return the empty value.

Does anyone know what this is about? or what should I modify so that the invocation to the SP with the new provider works?

Best regards to all.

    
asked by RSillerico 17.09.2016 в 01:12
source

1 answer

1

Using ODAC , this is how I work with a store procedure :

Using cn As OracleConnection = Conexion.Conectar("default")
    cn.Open()
    Using cmd As OracleCommand = cn.CreateCommand()
        cmd.CommandText = "Prueba2.pakclientes.usp_addcliente"
        cmd.CommandType = CommandType.StoredProcedure
        With cmd.Parameters
            .Add("int_idcliente", OracleDbType.Int32, ParameterDirection.Input).Value = cliente.IdCliente
            .Add("str_ruc", OracleDbType.Varchar2, 11, ParameterDirection.Input).Value = cliente.Ruc
            .Add("str_nombre", OracleDbType.Varchar2, 80, ParameterDirection.Input).Value = cliente.Nombre
            .Add("str_razonsocial", OracleDbType.Varchar2, 100, ParameterDirection.Input).Value = cliente.RazonSocial
            .Add("str_direccion", OracleDbType.Varchar2, 100, ParameterDirection.Input).Value = cliente.Direccion
        End With
        cmd.ExecuteNonQuery()
    End Using
End Using

And not having to be declaring each parameter that you are going to use.

    
answered by 17.09.2016 в 02:36