Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have write these code for change my password on first login but this code is getting error here is my code

C#
using (extractDataContext context = new extractDataContext())
{
var Query = (from t in context.userDetails where txtUserID.Text == t.UserID && SimpleHash.Encrypt_QueryString(txtPassword.Text ) == t.Password select new { t.Password }).Single();

if (Query!=null)
{
Query .Password = SimpleHash.Encrypt_QueryString(txtPassword.Text);  --> Error Shows in bolted text
context.SubmitChanges();
}

}
Posted
Updated 19-Jan-15 18:15pm
v3

1 solution

Please Change Single to FirstOrDefault or First.Single returns a scalar value.So you can't use it like property
C#
var Query = (from t in context.userDetails where txtUserID.Text == t.UserID && SimpleHash.Encrypt_QueryString(txtPassword.Text ) == t.Password select new { t.Password }).FirstOrDefault();

Hope this helps
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900