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?

Carlos SanchezRank #6,113 · 276 reputationPosted Oct 27, 2004, 8:09 AM EDT
eksypnos12365 reputationPosted Oct 27, 2004, 12:29 PM EDT
p.jones132 reputationPosted Nov 4, 2004, 5:44 AM EST