title: C# Odbc Query Result Incorrect
body: <p>I am struggling here trying to understand (after a lot of research a futzing with this) why my MySQL query in C# is returning only one row and the values are wrong.</p>
  
  <pre><code>public static void loadCombinedPaymentExportData(Int32 iFromId = 0)
  {
      // VERIFIED STATE OF CONNECTION (OUTPUTS "OPEN")
      Console.Write(oConn.State+"\n");
  
      // TRIED USING PREPARED STATEMENTS FIRST
      //OdbcCommand oCommand = new OdbcCommand("SELECT * FROM v_payment_export_combined_rec WHERE id &gt; ? LIMIT 10", oConn);
      //oCommand.Parameters.Add("@ID", OdbcType.Int).Value = iFromId;
  
      // ENDED UP TRYING A MORE DIRECT APPROACH SO I COULD SEE WHAT IS HAPPENING
      string sQuery = "SELECT * FROM v_payment_export_combined_rec WHERE id &gt; " + iFromId.ToString() + " LIMIT 10";
  
      // OUTPUTS "SELECT * FROM v_payment_export_combined_rec WHERE id &gt; 0 LIMIT 10"
      Console.WriteLine(sQuery);
  
      OdbcCommand oCommand = new OdbcCommand(sQuery, oConn);
      using (OdbcDataReader oReader = oCommand.ExecuteReader())
      {
          // THIS ENTERS INTO THE BLOCK AS HAVING ROWS
          if (oReader.HasRows)
          {
              while (oReader.Read())
              {
                  // THIS ONLY OUTPUTS ONCE AS "Data: 1"
                  Console.WriteLine("\nData: {0}", oReader.GetString(0));
              }
          }
          else
          {
              Console.WriteLine("No rows found.\n");
          }
  
          oReader.Close();
          oCommand.Dispose();
      }
  }
  </code></pre>
  
  <p>The issue here is if I run the same exact query on the database using my SQL editor, I have something like 190k+ rows come back from the view, and the lowest <code>id</code> is 8. In fact, I tried adding additional output like:</p>
  
  <pre><code>Console.WriteLine("\nData: {0} | {1} | {2}", oReader.GetString(0), oReader.GetString(1), oReader.GetString(2));
  </code></pre>
  
  <p>And every single one of them comes back as a <strong>1</strong>, which is incorrect as the 2nd column has real text.</p>
  
  <p><img src="https://i.stack.imgur.com/GB4dn.png" alt="enter image description here"></p>
  
  <p>Curiously, I had previously done a similar test on another table using this same logic and it worked just fine.</p>
  
  <p>What am I messing up?</p>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>Just tried using the MySQL .NET Connector instead of ODBC and got the same result.</p>
  
  <pre><code>string sQuery = "SELECT * FROM v_payment_export_combined_rec WHERE id &gt; " + iFromId.ToString() + " LIMIT 10;";
  
  MySqlCommand oCommand = new MySqlCommand(sQuery, oConn);
  using (MySqlDataReader oReader = oCommand.ExecuteReader())
  {
      if (oReader.HasRows)
      {
          while (oReader.Read())
          {
              Console.WriteLine("\nData: {0}", oReader.GetString(0));
          }
      }
      else
      {
          Console.WriteLine("No rows found.\n");
      }
  
      oReader.Close();
      oCommand.Dispose();
  }
  </code></pre>
  
  <p>I will keep investigating here to see if I can figure out what is going on.</p>