locked
EntLib 6 Data Access Block with Oracle 11G - Why select doesn't return values? RRS feed

  • Question

  • To clarify this code works with other tables and views. When trying to access SYS.v_$archive_log no error is thrown but know results are returned. Please help me understand what I am doing incorrectly.

    ---------- Code Sample Below -------------------------

    using EntLibContrib.Data.OdpNet;
    using Microsoft.Practices.EnterpriseLibrary.Common;
    using Microsoft.Practices.EnterpriseLibrary.Data;
    using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
    using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
    using Microsoft.Practices.EnterpriseLibrary.Logging;
    using Microsoft.Practices.EnterpriseLibrary.Logging.Database;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace A_DataGuard_Checker
    {
        class Program
        {
            static void Main(string[] args)
            {
                // Configure the DatabaseFactory to read its configuration from the app.config file
                DatabaseProviderFactory factory = new DatabaseProviderFactory();

                // Create a database object from the factory using the connection string name.
                Database example = factory.Create("orcl");

                // Call the ExecuteReader method by specifying the command type
                // as a SQL statement, and passing in the SQL statement.
                using (IDataReader reader = example.ExecuteReader(CommandType.Text, "select * from sys.v_$archived_log"))
                {
                    // Display the values
                    DisplayRowValues(reader);
                }
                Console.WriteLine("Press <enter> to exit...");
                Console.ReadLine();
            }

            static void DisplayRowValues(IDataReader reader)
            {
                while (reader.Read())
                {
                    for (int i =0; i < reader.FieldCount; i++)
                    {
                        Console.WriteLine("{0} = {1}", reader.GetName(i), reader[i].ToString());
                    }
                }
            }
        }
    }


    Brett L. Brown

    Tuesday, February 25, 2014 6:00 PM

All replies

  • Hi Brett,

    Per my understanding, I think there is no unusual stuff within your code. When you said no error is thrown but no results are returned, please check did you enable ARCHIVELOG mode for your Oracle Database. For more information, see the following link. http://www.cuddletech.com/articles/oracle/node58.html.

    Hope useful.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, February 26, 2014 2:49 AM
  • ArchiveLog is turned and I can query. What I've noticed in EntLib6 creating the factory, then a database object, does not return results.

    If I do this (see below) I get the expected results. The problem is the entlib6 pattern doesn't return results:

    string conStr = "User Id=auser;Password=;Data Source=asource";
    OracleDatabase orcl = new OracleDatabase(conStr);

     

    DataSet myDS = new DataSet("myDS");

    string mySqlQuery = "select thread# as Primary_DBThread#, max(sequence#) as LastPrimary_Generated from v$archived_log group by thread# order by 1";

    primary_Aligne.LoadDataSet(CommandType.Text, mySqlQuery, myDS, new string[] { "Primary" });

    It sure would be nice if someone else can confirm they see the same. The sql query above is generic and should work with any oracle database with archivelog enabled.

     

     

     

     

     


    Brett L. Brown

    Friday, February 28, 2014 4:26 AM
  • Hi Brett,

    It’s a strange thing. If the connection is ok, I think there probably be some mistake in your sql statement. You should get the select query at the runtime and copy them to run in your oracle db to see the result.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 28, 2014 6:08 AM