Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
C#
{
       Sql = "select * from BirthDayWish where Active = 'A'";
       Dr = SCon.ReadSql(Sql);
       GridView1.DataSource = Dr;
       GridView1.DataBind();
       GridView1.Visible = true;
   }



in the above sql query.
SQL
Sql = "select * from BirthDayWish where Active = 'A'";

i want to use OrderBy Name.

how to use.

i am using the below query,this is correct.

SQL
sql="select * from BirthDayWish OrderBy Name where Active='A'";


the above query is correct.


pleae help me.and send the query;
Posted
Updated 27-Dec-12 2:29am
v2

Order By[^] Clause comes after Where clause.
So your query should be
SQL
select * from BirthDayWish where Active='A' Order By [Name] 
 
Share this answer
 
v2
Comments
Aarti Meswania 27-Dec-12 7:01am    
My 5+! :)
__TR__ 27-Dec-12 7:18am    
Thank you Aarti.
Aarti Meswania 27-Dec-12 7:21am    
welcome! :)
[no name] 27-Dec-12 7:13am    
my 5
__TR__ 27-Dec-12 7:18am    
Thank you Mitesh.
Hi it would be much better if specify all columns that you want to fetch:

sql="select Id,Name,Active from BirthDayWish WHERE Active='A' Order By Name ASC";
 
Share this answer
 
Comments
[no name] 27-Dec-12 7:26am    
it is not compulsory to write ASC in order. because it is by default order.
Oleksandr Kulchytskyi 27-Dec-12 7:37am    
I knew it ;)
But anyway thanks, i think it will be useful for questioner!
[no name] 27-Dec-12 7:39am    
ok. i updated the Rate that i given..
C#
{
 Sql = "select * from BirthDayWish where Active = 'A'";
 Dr = SCon.ReadSql(Sql);
 Dr.DefaultView.Sort = "Name ASC";
 GridView1.DataSource = Dr;
 GridView1.DataBind();
 GridView1.Visible = true;
 }
 
Share this answer
 
v3
Comments
[no name] 27-Dec-12 7:25am    
my 5+
Try This
In Ascending Order By Name:
SQL
select * 
from BirthDayWish 
where Active = 'A'
Order By Name

In Descending Order By Name:
SQL
select *
from BirthDayWish
where Active = 'A'
Order By Name Desc
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900