Dataset holds a table called "Table", not the table I pass in?
<p>I have the code below:</p>

<pre><code>string SQL = "select * from " + TableName;

using (DS = new DataSet())
using (SqlDataAdapter adapter = new SqlDataAdapter())
using (SqlConnection sqlconn = new SqlConnection(connectionStringBuilder.ToString()))
using (SqlCommand objCommand = new SqlCommand(SQL, sqlconn))
{
    sqlconn.Open();
    adapter.SelectCommand = objCommand;
    adapter.Fill(DS);
}

System.Windows.Forms.MessageBox.Show(DS.Tables[0].TableName);

return DS;
</code></pre>

<p>However, every time I run this code, the dataset (DS) is filled with one table called "Table". It does not represent the table name I pass in as the parameter TableName and this parameter does not get mutated so I don't know where the name Table comes from. I'd expect the table to be the same as the tableName parameter I pass in?</p>

<p>Any idea why this is not so?</p>

<p>EDIT: Important fact: This code needs to return a dataset because I use the dataRelation object in another method, which is dependent on this, and without using a dataset, that method throws an exception. The code for that method is:</p>

<pre><code>DataRelation PartToIntersection = new DataRelation("XYZ", 
        this.LoadDataToTable(tableName).Tables[tableName].Columns[0],
        // Treating the PartStat table as the parent - .N
        this.LoadDataToTable("PartProducts").Tables["PartProducts"].Columns[0]);
        // 1

        // PartsProducts (intersection) to ProductMaterial
        DataRelation ProductMaterialToIntersection = 
           new DataRelation("", ds.Tables["ProductMaterial"].Columns[0],
                                ds.Tables["PartsProducts"].Columns[1]);
</code></pre>

<p>Thanks</p>
