我在按钮里这样写的代码 会员DataContext 会员 = new 会员DataContext();        会员表 dd = (from c in 会员.会员表
                  where c.邮箱 == this.txtEmail.Text
                  select c).First();        if (dd.邮箱 != null)
        {
            Response.Write("数据库里有这个邮箱名");
        }
        else
        {
            Response.Write("没查到这个邮箱哎!");
        }这样写不对哎,假如我输入正确的邮箱,就不报错,如果输入数据库中没有的,就报错,请问这个linq与语句应该怎么写啊还有,我if (dd.邮箱 != null)这样判断对不对啊,断点都不经过这里,因为linq语句错了!

解决方案 »

  1.   

    会员DataContext 会员 = new 会员DataContext();        会员表 dd = (from c in 会员.会员表
                      where c.邮箱 == this.txtEmail.Text
                      select c).FirstOrDefault();        if (dd != null )
            {
                Response.Write("数据库里有这个邮箱名");
            }
            else
            {
                Response.Write("没查到这个邮箱哎!");
            }
    论坛签名======================================================================dzynihao:你好!
    截至 2011-03-16 14:10:42 前:
    你已发帖 17 个, 未结贴 3 个;
    结贴率为: 82.35%

    当您的问题得到解答后请及时结贴.

    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
    http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
    http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html如何给分和结贴?
    http://community.csdn.net/Help/HelpCenter.htm#结帖如何给自己的回帖中也加上签名?
    http://blog.csdn.net/q107770540/archive/2011/03/15/6250007.aspx