locked
Sorting a databound combobox RRS feed

  • Question

  • Hi,

     

    I have a SqlCeResultSet that queries a Customers table with TableDirect command type.

    I set the DataSource of a BindingSource to the SqlCeResultSet and then set the DataSource of a ComboBox to the BindingSource.

    I also set the Sort property of the BindingSource equal to Name which is the column name that I am interested in. When I run the application, sorting is not accomplished.

     

    Thanks,

     

    Aristeidis Bampakos

    Thursday, May 26, 2011 10:59 AM

Answers

  • Then you either stop using this command type and use select statement or you add index to your database which sorts data in order you want and set it on TableDirect command.

    Generally since SQL CE 3 there's no good reason to use TableDirect except may be to insert data with RS. All it does is bypasses QP thus eliminating a lot of useful functionality which you would have to do on your own (e.g, load data into memory and sort it) while not providing significant performance gain.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, May 27, 2011 4:02 PM

All replies

  • With result set sorting is determined by SQL command which is used to execute result set. Consider using select statement with 'order by' clause to fetch your data.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, May 26, 2011 4:05 PM
  • What if the CommandType of the CommandText is TableDirect and not SELECT statement?
    Friday, May 27, 2011 9:44 AM
  • Then you either stop using this command type and use select statement or you add index to your database which sorts data in order you want and set it on TableDirect command.

    Generally since SQL CE 3 there's no good reason to use TableDirect except may be to insert data with RS. All it does is bypasses QP thus eliminating a lot of useful functionality which you would have to do on your own (e.g, load data into memory and sort it) while not providing significant performance gain.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, May 27, 2011 4:02 PM