title: How do I get MySQLDataAdapter to set the table name and columns using TableMapping?
body: <p>I am trying to gain an understanding of how TableMapping works. The code below should retrieve a single row from <strong>[testing].[testtable]</strong>:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">column_a</th>
  <th style="text-align: center;">column_b</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">entry 1</td>
  <td style="text-align: center;">value 1</td>
  </tr>
  <tr>
  <td style="text-align: center;">entry 2</td>
  <td style="text-align: center;">value 2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I would like the retrieved <em>DataSet</em> to contain a table named <strong>MyData</strong> with the &quot;<em>entry 1</em>&quot; value in a column named <strong>MyDataA</strong> and the &quot;<em>value 1</em>&quot; value in a column named <strong>MyDataB</strong>.</p>
  <p>However, the code below only names the table as desired. i.e.</p>
  <p><strong>ds.Tables[&quot;MyData&quot;].Rows[0][&quot;MyDataA&quot;]</strong> throws an error while</p>
  <p><strong>ds.Tables[&quot;MyData&quot;].Rows[0][&quot;column_a&quot;]</strong> returns &quot;<em>entry 1</em>&quot;.</p>
  <p>This is the opposite of what I want. I have tried reversing the parameters passed in the <em>dtm.ColumnMappings.Add()</em> statements, but to no avail.</p>
  <p>Can someone tell me what I am doing wrong? Or do I have a gross misunderstanding of what TableMapping is supposed to do?</p>
  <pre><code>using var connection = new MySqlConnection(&quot;Server=localhost;Database=testing;Uid=dev;Pwd=notmyrealpassword;AllowUserVariables=True;&quot;);
  connection.Open();
      
  var sql = &quot;SELECT column_a, column_b FROM testtable WHERE column_a=@p1;&quot;;
      
  var da = new MySqlDataAdapter(sql, connection);
  da.SelectCommand.Parameters.AddWithValue(&quot;@p1&quot;, &quot;entry 1&quot;);
      
  var dtm = da.TableMappings.Add(&quot;testtable&quot;, &quot;MyData&quot;);
  dtm.ColumnMappings.Add(&quot;column_a&quot;, &quot;MyDataA&quot;);
  dtm.ColumnMappings.Add(&quot;column_b&quot;, &quot;MyDataB&quot;);
      
  var ds = new DataSet();
  da.Fill(ds, &quot;MyData&quot;);
  </code></pre>