passing a different sql string to DataAdapter each time i click a button
private void button1_Click(object sender, System.EventArgs e)
{
ds.Tables.Clear();
da.SelectCommand=new SqlCommand(textBox1.Text,sqlConnection1);
da.Fill(ds,"myTable");
dataGrid1.SetDataBinding(ds,"myTable");
}
I have a form with a textBox1, a dataGrid1 and a button1. In the textBox1 I write some sql code and I want to see the output in the grid. ds is a dataset and da is a dataAdapter that were instantiated once in the constructor without any parameters. (ds=new DataSet(), da=New DataAdapter()).
My problems is that this code seems to execute only the first time I click the button. After the first time the datagrid doesn't change although i put different sql code in the textBox.
Can somebody tell me why is this happening?