title: C# Oracle OracleDataReader.Read()
body: <p>I've ran into a little problem with my Oracle and C#. When I'm running this query it returns 0 rows, so rd.Read() = false. But it's weird, because there are records in the database. Running the exact same query in SQL Developer returns 2 rows. </p>
  
  <p>I'm running Oracle XE 11.2</p>
  
  <p>Can anyone maybe explain why dr.Read() returns false?</p>
  
  <p>EDIT: Connecting to the database works 100%.</p>
  
  <pre><code>    public List&lt;ChatMessage&gt; ReceiveMessage(string account_ID, string account_ID2)
      {
          //Initialize list of strings for all the messages
          List&lt;ChatMessage&gt; list = new List&lt;ChatMessage&gt;();
  
          //Make connection
          OracleConnection con = new OracleConnection(connstring);
          con.Open();
  
          //Make query
          string query = "SELECT Sender_ID, Receiver_ID, Message, Msg_Date FROM TBL_CHAT WHERE Sender_ID = '1' AND Receiver_ID = '2' OR Sender_ID = '2' AND Receiver_ID = '1' ORDER BY Msg_Date DESC";
  
          //Add parameters
          OracleCommand cmd = new OracleCommand();
          //cmd.Parameters.Add("account_ID", account_ID);
          //cmd.Parameters.Add("account_ID2", account_ID2);
  
          cmd.Connection = con;
          cmd.CommandText = query;
  
          //Execute query and initialize reader
          OracleDataReader dr = cmd.ExecuteReader();
  
          //Start reading the messages and add them to a list
          while(dr.Read())
          {
              string sender_ID = dr.GetString(0);
              string receiver_ID = dr.GetString(1);
              string message = dr.GetString(2);
              DateTime date = dr.GetDateTime(3);
  
              ChatMessage msg = new ChatMessage(message, sender_ID, receiver_ID, date);
              list.Add(msg);
          }
  
          //Close database
          con.Close();
  
          return list;
      }
  </code></pre>