When my form first loaded, I use SqlDataAdapter.Fill to add a table into a DataSet.
this.bus_SqlDataAdapter.SelectCommand.CommandText = "select * from Bus"
this.bus_SqlDataAdapter.Fill(this.bus_DataSet, "Bus");
this.bus_DataGridView.DataSource = this.bus_DataSet;
this.bus_DataGridView.DataMember = "Bus";
Then I use a button which will change the query and update the Bus table:
this.bus_SqlDataAdapter.SelectCommand.CommandText = "select * from Bus where ID = 1"
try
{
this.bus_DataSet.Tables.Remove("Bus");
}
catch
{
//Don't do anything
}
finally
{
this.bus_SqlDataAdapter.Fill(this.bus_DataSet, "Bus");
}
But the data in DataGridView remains the same. What was happened and how can I fix it?