Click here to Skip to main content
11,484,752 members (62,550 online)
Rate this: bad
good
Please Sign up or sign in to vote.
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 = "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="select * from BirthDayWish OrderBy Name where Active='A'";

the above query is correct.


pleae help me.and send the query;
Posted 27-Dec-12 1:01am
Edited 27-Dec-12 3:29am
ridoy53.4K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Order By[^] Clause comes after Where clause.
So your query should be
select * from BirthDayWish where Active='A' Order By [Name] 
  Permalink  
v2
Comments
Aarti Meswania at 27-Dec-12 7:01am
   
My 5+! :)
__TR__ at 27-Dec-12 7:18am
   
Thank you Aarti.
Aarti Meswania at 27-Dec-12 7:21am
   
welcome! :)
__TR__ at 27-Dec-12 7:18am
   
Thank you Mitesh.
Madhuri Patil at 27-Dec-12 8:18am
   
My 5
__TR__ at 27-Dec-12 11:08am
   
Thank you Madhuri.
ridoy at 27-Dec-12 8:29am
   
+5
__TR__ at 27-Dec-12 11:08am
   
Thank you ridoy.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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";
  Permalink  
Comments
Oleksandr Kulchytskyi at 27-Dec-12 7:37am
   
I knew it ;)
But anyway thanks, i think it will be useful for questioner!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

{
 Sql = "select * from BirthDayWish where Active = 'A'";
 Dr = SCon.ReadSql(Sql);
 Dr.DefaultView.Sort = "Name ASC";
 GridView1.DataSource = Dr;
 GridView1.DataBind();
 GridView1.Visible = true;
 }
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Try This
In Ascending Order By Name:
select * 
from BirthDayWish 
where Active = 'A'
Order By Name
In Descending Order By Name:
select *
from BirthDayWish
where Active = 'A'
Order By Name Desc
  Permalink  
v2

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

  Print Answers RSS
0 Maciej Los 190
1 Sergey Alexandrovich Kryukov 180
2 Raje_ 155
3 OriginalGriff 147
4 Mehdi Gholam 120
0 Sergey Alexandrovich Kryukov 8,494
1 OriginalGriff 7,948
2 Sascha Lefèvre 3,199
3 Maciej Los 2,681
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100