查询显示字符串而不是数据库值 [英] query for display string instead of database value

查看:116
本文介绍了查询显示字符串而不是数据库值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从数据库中获取数据到gridview;
我有两个领域
1.用户
2.状态
状态检查用户是否处于活动状态
如果为活动",则状态应为1而不是"0"
问题是我想在网格视图中显示活动"而不是"1",而不是非活动用户"而不是"0"

I want to fetch data from database to gridview;
I have two fields
1.User
2.Status
Status Check whether the user is active or not
If ''active'', status should be 1 and not ''0''
The problem is i want to display in my gridview ''active'' instead of ''1'' and ''not an active user'' instead of ''0''

推荐答案

像这样使用您的sql SELECT采石场

use your sql SELECT quarry like this

SELECT User,NewStatus=CASE Status WHEN 1 THEN 'Active' ELSE 'not an active' END
FROM your_table_name
where your_where_condition_if_needed



希望这可以帮助您解决问题.

有关更多详细信息
http://msdn.microsoft.com/en-us/library/ms181765.aspx [ ^ ]



I hope this will help you to solve your problem.

for more details
http://msdn.microsoft.com/en-us/library/ms181765.aspx[^]


这篇关于查询显示字符串而不是数据库值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆