title: How to read the result of SELECT * from joined tables with duplicate column names in .NET
body: <p>I am a PHP/MySQL developer, slowly venturing into the realm of C#/SQL Server and I am having a problem in C# when it comes to reading an SQL Server query that joins two tables.</p>
  <p>Given the two tables:</p>
  <p>TableA:</p>
  <pre><code>int:id
  VARCHAR(50):name
  int:b_id
  </code></pre>
  <p>TableB:</p>
  <pre><code>int:id
  VARCHAR(50):name
  </code></pre>
  <p>And given the query</p>
  <pre><code>SELECT * FROM TableA,TableB WHERE TableA.b_id = TableB.id;
  </code></pre>
  <p>Now in C# I normally read query data in the following fashion:</p>
  <pre><code>SqlDataReader data_reader= sql_command.ExecuteReader();
  data_reader[&quot;Field&quot;];
  </code></pre>
  <p>Except in this case I need to differentiate from TableA's name column, and TableB's name column.</p>
  <p>In PHP I would simply ask for the field &quot;TableA.name&quot; or &quot;TableB.name&quot; accordingly but when I try something like</p>
  <pre><code>data_reader[&quot;TableB.name&quot;];
  </code></pre>
  <p>in C#, my code errors out.</p>
  <p>How can fix this? And how can I read a query on multiple tables in C#?</p>