Click here to Skip to main content
15,905,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have an SQL database with 2 data tables. One Table has a column which is of type int. The value of that column will be 1, 2, 3 or 4. In my application these numbers have different meanings like
1 - "Started"
4 - "End"
2- "Paused"
3 - "Restart"

Currently i am reading the column value as 1,2,3 etc and converting to respective strings. Say for example if i get column value as 1, i am comparing and converting it as "Started".

Is there any way to display the data same as 1,2,3 or 4 in data table and while retrieving, get the output as string like "Started" or "paused" ? Then i can avoid comparing the integers and getting respective strings pragmatically.
Posted
Updated 5-Jan-12 23:45pm
v2

 
Share this answer
 
Comments
code4Better 6-Jan-12 5:47am    
Your solution is just accessing data from a data table. My question is different from it
hi
use case statement in select query.


Select status = case when 1 then 'Started' when 4 then 'end' when 2 then 'Pushed' when 3 then 'Restart' end
 
Share this answer
 
Comments
code4Better 6-Jan-12 7:02am    
Thanks Tushar, 'case' works 4 me.
In combo box we can have display member and value member. Is there any such option for data table columns??

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