Comparing textbox.text value to value in SQL Server
Posted
by Anicho
on Stack Overflow
See other posts from Stack Overflow
or by Anicho
Published on 2010-04-15T14:34:04Z
Indexed on
2010/05/26
19:51 UTC
Read the original article
Hit count: 282
Okay so I am trying to compare a login textbox password and username with a custom validator using linq to get information from the database it always returns false though on the validator could someone please tell me where my code below is going wrong. This will be very much appreciated... thank you in advanced...
protected void LoginValidate(object source, ServerValidateEventArgs args)
{
TiamoDataContext context = new TiamoDataContext();
var UsernameCheck = from User in context.Users
where User.Username == TextBoxLoginUsername.Text && User.Password == TextBoxLogInPassword.Text
select User.Username;
var PasswordCheck = from User in context.Users
where User.Username == TextBoxLoginUsername.Text && User.Password == TextBoxLogInPassword.Text
select User.Password;
String test1 = PasswordCheck.ToString();
String test2 = UsernameCheck.ToString();
if (test1 == TextBoxLogInPassword.Text && test2 == TextBoxLoginUsername.Text)
{
args.IsValid = true;
Session["Username"] = TextBoxLoginUsername;
Response.Redirect("UserProfile.aspx");
}
else
{
args.IsValid = false;
}
}
I dont know where I am going wrong I know its most probably some sort of silly mistake and me being inexperienced at this...
© Stack Overflow or respective owner