I have the following code:
DataClasses1DataContext db = new DataClasses1DataContext();
var UserInfo = db.Users.FirstOrDefault(u => u.Email == TextBox1.Text);
if (UserInfo.Email != null)
{
Label2.Text = "Email is not null";
}
else
{
Label2.Text = "Email is null";
}
If an email address exists in the table, it successfully prints "Email is not zero." However, if there is no corresponding entry, I get a link to an object that is not set to an instance of an object error for line 29:
Line 27: DataClasses1DataContext db = new DataClasses1DataContext ();
Line 28:
Line 29: var UserInfo = db.Users.FirstOrDefault (u => u.Email == TextBox1.Text);
Line 30:
Line 31: if (UserInfo.Email! = Null)
I'm at a dead end! Any help would be greatly appreciated.