DataBoundGrid and changing sql query

I added a DataBoundGrid control and setup an initial sql select statement for it's data. I'd like to add some functionality to change the sql statement based on a button click. I was browsing through the code and the Adapter has a private member called _commandCollection with my initial sql select statement, but I see no way to access this and change this collection. How can I tell my adapter to start using a different sql select statement?


1 Reply

AD Administrator Syncfusion Team December 12, 2007 12:26 PM UTC

You might try setting the DataAdapter.SelectCommand property if you are querying the same DataTable that is the grid's DataSource.

private void button1_Click(object sender, EventArgs e)
{
string connString = @"Provider=Microsoft.JET.OLEDB.4.0;data source=" + GetPath(@"Data\nwind.mdb");
string sqlString = "SELECT EmployeeID, FirstName, LastName, Photo, Photo as Photo1 FROM Employees where [LastName] LIKE 'King'";

OleDbConnection connection = new OleDbConnection(connString);

this.dataAdapter.SelectCommand = new OleDbCommand(sqlString, connection);
this._dataSet.Tables["Employees"].Clear();
this.dataAdapter.Fill(_dataSet, "Employees");
connection.Close();

}



Loader.
Up arrow icon