Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Empty record returned with this query when querying Oracle database with .NET but gave rows in SQL+

Empty record returned with this query when querying Oracle database with .NET but gave rows in SQL+

Scheduled Pinned Locked Moved C#
databasecsharporaclesysadminxml
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    awedaonline
    wrote on last edited by
    #1

    Hello guys; The code below returns an empty records but gave records from SQL+.

    DbProviderFactory factory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client");
    DbConnection connection = factory.CreateConnection();
    
    connection.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS\_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=Simplex-IT-02)(PORT=1521)))
                         (CONNECT\_DATA=(SERVER=DEDICATED)(SERVICE\_NAME=Simplex))); User Id=User\_Test;Password=password;";
    
    DataTable table = new DataTable();
    
    DbCommand command = connection.CreateCommand();
    command.Connection = connection;
    command.CommandText = "SELECT text FROM user\_views WHERE (view\_name='ACCOUNT\_BALANCES\_BY\_PERIOD');";
    
    DbDataReader dataReader = command.ExecuteReader();
    
    table.Load(dataReader);
    dataReader.Close();
    

    Meanwhile, when I replaced the command.CommandText with "SELECT DISTINCT view_name FROM user_views" it gave me list of all available views for the given schema. Why can't I get the sql text of a given view? Thank you in anticipation.

    S J P 3 Replies Last reply
    0
    • A awedaonline

      Hello guys; The code below returns an empty records but gave records from SQL+.

      DbProviderFactory factory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client");
      DbConnection connection = factory.CreateConnection();
      
      connection.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS\_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=Simplex-IT-02)(PORT=1521)))
                           (CONNECT\_DATA=(SERVER=DEDICATED)(SERVICE\_NAME=Simplex))); User Id=User\_Test;Password=password;";
      
      DataTable table = new DataTable();
      
      DbCommand command = connection.CreateCommand();
      command.Connection = connection;
      command.CommandText = "SELECT text FROM user\_views WHERE (view\_name='ACCOUNT\_BALANCES\_BY\_PERIOD');";
      
      DbDataReader dataReader = command.ExecuteReader();
      
      table.Load(dataReader);
      dataReader.Close();
      

      Meanwhile, when I replaced the command.CommandText with "SELECT DISTINCT view_name FROM user_views" it gave me list of all available views for the given schema. Why can't I get the sql text of a given view? Thank you in anticipation.

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      Just a suggestion what if you give the "text" column name an alias? Oracle Column name as alias example[^]

      Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

      A 1 Reply Last reply
      0
      • S Simon_Whale

        Just a suggestion what if you give the "text" column name an alias? Oracle Column name as alias example[^]

        Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

        A Offline
        A Offline
        awedaonline
        wrote on last edited by
        #3

        Simon_Whale wrote:

        Just a suggestion what if you give the "text" column name an alias?

        Thank you for the suggestion but I have already done that and it didn't work.

        S 1 Reply Last reply
        0
        • A awedaonline

          Simon_Whale wrote:

          Just a suggestion what if you give the "text" column name an alias?

          Thank you for the suggestion but I have already done that and it didn't work.

          S Offline
          S Offline
          Simon_Whale
          wrote on last edited by
          #4

          Have you read this one? https://forums.oracle.com/forums/thread.jspa?threadID=258409[^]

          Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

          L A 2 Replies Last reply
          0
          • S Simon_Whale

            Have you read this one? https://forums.oracle.com/forums/thread.jspa?threadID=258409[^]

            Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            This could be related to ANSI Code Settings. Ray Yagubyan

            1 Reply Last reply
            0
            • S Simon_Whale

              Have you read this one? https://forums.oracle.com/forums/thread.jspa?threadID=258409[^]

              Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

              A Offline
              A Offline
              awedaonline
              wrote on last edited by
              #6

              Simon_Whale wrote:

              https://forums.oracle.com/forums/thread.jspa?threadID=258409[^]

              Thank you for the reference. But I tried it and still didn't get it working.

              1 Reply Last reply
              0
              • A awedaonline

                Hello guys; The code below returns an empty records but gave records from SQL+.

                DbProviderFactory factory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client");
                DbConnection connection = factory.CreateConnection();
                
                connection.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS\_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=Simplex-IT-02)(PORT=1521)))
                                     (CONNECT\_DATA=(SERVER=DEDICATED)(SERVICE\_NAME=Simplex))); User Id=User\_Test;Password=password;";
                
                DataTable table = new DataTable();
                
                DbCommand command = connection.CreateCommand();
                command.Connection = connection;
                command.CommandText = "SELECT text FROM user\_views WHERE (view\_name='ACCOUNT\_BALANCES\_BY\_PERIOD');";
                
                DbDataReader dataReader = command.ExecuteReader();
                
                table.Load(dataReader);
                dataReader.Close();
                

                Meanwhile, when I replaced the command.CommandText with "SELECT DISTINCT view_name FROM user_views" it gave me list of all available views for the given schema. Why can't I get the sql text of a given view? Thank you in anticipation.

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #7

                awedaonline wrote:

                The code below returns an empty records but gave records from SQL+.

                That isn't clear. Are you saying it returned zero records or that that returns some records but there was no data in the records? What values are returned by the following properties? dataReader.FieldCount dataReader.HasRows What is the data type of 'text' in the database?

                1 Reply Last reply
                0
                • A awedaonline

                  Hello guys; The code below returns an empty records but gave records from SQL+.

                  DbProviderFactory factory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client");
                  DbConnection connection = factory.CreateConnection();
                  
                  connection.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS\_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=Simplex-IT-02)(PORT=1521)))
                                       (CONNECT\_DATA=(SERVER=DEDICATED)(SERVICE\_NAME=Simplex))); User Id=User\_Test;Password=password;";
                  
                  DataTable table = new DataTable();
                  
                  DbCommand command = connection.CreateCommand();
                  command.Connection = connection;
                  command.CommandText = "SELECT text FROM user\_views WHERE (view\_name='ACCOUNT\_BALANCES\_BY\_PERIOD');";
                  
                  DbDataReader dataReader = command.ExecuteReader();
                  
                  table.Load(dataReader);
                  dataReader.Close();
                  

                  Meanwhile, when I replaced the command.CommandText with "SELECT DISTINCT view_name FROM user_views" it gave me list of all available views for the given schema. Why can't I get the sql text of a given view? Thank you in anticipation.

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  My first thought is to remove the semi-colon from the end of the statement. Many ADO.net providers don't like executing a batch of statements. P.S. I get the following when I try to execute "SELECT * FROM dual;" Oracle.DataAccess.Client.OracleException: ORA-00911: invalid character I hope your classes aren't swallowing Exceptions.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups