We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataBoundGrid and changing sql query

Thread ID:

Created:

Updated:

Platform:

Replies:

70444 Dec 11,2007 04:45 PM UTC Dec 12,2007 12:26 PM UTC Windows Forms 1
loading
Tags: GridControl
Mohan Khurana
Asked On December 11, 2007 04:45 PM UTC

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?


Administrator [Syncfusion]
Replied On 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();

}



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;