0

I retrive data from a table to a datagridview.
I want the coulmns to be in a sorted according to their names
ex: column starting with 'a' should come before that of 'b' and so on
Is there any SQL querry for the above problem or any function in datagridview which can be used.

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by selvaganapathy
0

Hi, you can Use
ORDER BY FieldName SQL in Queries. This will sort and Display in sorted order in DataGridView.
Syntax

SELECT fieldlist
FROM table
WHERE selectcriteria
[ORDER BY field1 [ASC | DESC ][, field2 [ASC | DESC ]][, ...]]]

Ex

SELECT LastName, FirstName
FROM Employees
ORDER BY LastName;

SELECT LastName, FirstName
FROM Employees
ORDER BY LastName ASC;
0

I think he means that the column (i.e. field names) names must be sorted. Not the records

0

I think he means that the column (i.e. field names) names must be sorted. Not the records

Ya, Sorry I was mistaken.

I want the coulmns to be in a sorted according to their names
ex: column starting with 'a' should come before that of 'b' and so on
Is there any SQL querry for the above problem or any function in datagridview which can be used.

One solution: Give the fields in ascending order in your SQL query. Or sort the fields by own and generate the SQL query on it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.