Click here to Skip to main content
15,902,922 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I am creating windows application using c# 2010, in my project using database sql server, how to shown table records display one by one using select command.

I want my final output
Ex :
Slno
1
2
3
4
5

but i got a result
Slno:
1
3
4
2
5
how to solve this error

any one give me some ideas.

What I have tried:

How to display records order by order in sql server
Posted
Updated 18-Jun-16 9:39am

Try:
SQL
SELECT * FROM MyTable ORDER BY Slno ASC
 
Share this answer
 
Comments
Boopalslm 18-Jun-16 11:46am    
yes i was tried already by not working
out put
Slno
1
2
5
6
10
9
8
7

give me some ideas
OriginalGriff 18-Jun-16 11:51am    
Show us the exact code you used to generate that sequence.
Michael_Davies 18-Jun-16 12:39pm    
What type is the field Slno; Integer? Varchar?

Show us the output from;

SELECT CONCAT("*",Slno,"*") FROM MyTable ORDER BY Slno ASC
Seems, Slno is varchar data type. To be able to sort data in correct order, you have to use proper data type (int).

But now, you can try something like this:
SQL
SELECT *
FROM TableName
ORDER CONVERT(INT, Slno) ASC


For further information, please see: CAST and CONVERT (Transact-SQL)[^]
 
Share this answer
 

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