2 Replies Latest reply: May 30, 2006 10:08 AM by 160495 RSS

    ODP.Net Ref Cursor and DbProviderFactory

      I am currently utilizing the ADO.Net Factory Provider method to create oracle connections, commands, and such. I am running into a problem when attempting to add a ref cursor as a parameter as seen below:

      DbProviderFactory factory =
      DbCommand command = factory.CreateCommand();
      DbDataReader reader;

      command.CommandText = commandName;
      command.CommandType = CommandType.StoredProcedure;

      DbParameter param = factory.CreateParameter();
      param.ParameterName = "refcursor";
      param.Value = null;
      param.Direction = ParameterDirection.Output;
      param.DbType = DbType.Object;

      When I try to set the DBType = Oracle.DataAccess.Client.OracleDbType.RefCursor I get an error.

      Is there a method to add a refcursor as a parameter and still utilize the generic method for creating oracle objects?
        • 1. Re: ODP.Net Ref Cursor and DbProviderFactory
          Did this question ever get answered? I've seen variations asked several different places but can't seem to find the answer. If I use DBType.Object, I get "invalid binding", but almost anything else seems to error out saying I have an invalid number of type of parameters (which makes sense). Am I just overlooking it?

          The ODP.Net manual seems to indicate that OracleDBType.RefCursor infrences DBType.Object but just can't make it work.

          Any help, pointers, etc. would be extremely appreciated.

          Thank you,
          • 2. Re: ODP.Net Ref Cursor and DbProviderFactory
            I have yet to get a solid answer on this. In the meantime I have some custom code for each driver type. If the current driver type is the oracle driver type I just to a cast to the Oracle type, in this case an OracleCommand and set the OracleDbType. Not the best solution but it does work.