i have a select in linq:
in if i must compare username and password for permitted,but a cant access to element of user.
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);
}
how can i give element of user?
Your
uservariable is a query which returns a sequence of matching users – not a single user.It sounds like you might want:
(I hope you don’t really have plain-text passwords, by the way…)