无法比较两个值..... [英] can not compare two values.....

查看:64
本文介绍了无法比较两个值.....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库表中的数据

data in my database table

id    int
name  varchar(50)
mode  char(10)





data in this table like
1   abc   L
2   mnj   C
3   oio   F
4   trt   L
5   lkl   L
6   rer   F



现在在页面加载时,我得到mode的单个值
喜欢



now on page load i get single value for mode
like

var q=(from a in obj.datas
       where a.id==1
       select a.mode).single();
now i want to compare this value with "L"
then how can i compare it



我用过



i used

if(q=="L")
{
  Response.write("This is for L");
}




但没有比较
我该如何比较,请给我适当的解决方案

谢谢




but did no compare
how can i compare please give me a proper solution

thank you

推荐答案

尝试使用q.Trim() == "L". VarChar类型会添加多余的空间来填充多余的空间,因此修剪将删除这些多余的空间,然后进行比较.

希望这会有所帮助,
Ed
Try using q.Trim() == "L". VarChar type adds extra spaces to fill the excess space so trim will remove these and the comparison should then work.

Hope this helps,
Ed


这篇关于无法比较两个值.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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