我有一个选择linq
:
如果我必须比较用户名和密码是否允许,但无法访问用户元素。
var user = from u in db.tbl_User select new {u.UserName,u.Password};
if(txtname == user && txtpass == pass)
{
Form2 frm = new Form2();
Visible = false;
frm.Show();
}
else
{
MessageBox.Show("Error","UserName or Password is wrong",MessageBoxButtons.OK);
}
我怎样才能给元素user
?