Finaly got the code.
int id = Convert.ToInt32(txtusername.Text);
db2Entities db = db2Entities();
string query = (from c in db.AdminTables
where c.AdminID == id && c.AdminPassword == txtpassword.Text
select c.AdminFirstName).FirstOrDefault();
if (query != null)
{
Response.Redirect("/Admin/Dasboard.aspx");
}
else
Response.Write("Invalid User");
try
{
db2Entities db = new db2Entities();
var query = (from c in db.AdminTables
where c.AdminPassword == txtoldpassword.Text
select c).FirstOrDefault();
query.AdminPassword = txtreenteredpassword.Text;
db.SaveChanges();
Label1.Visible = true;
Label1.Text = " Password Changed Sucessfully";
Response.Write("Password Changed Sucessfully");
}
catch (Exception ex )
{
Label1.Visible = true;
Label1.Text = " Error occured in Pasword changing";
}