Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am new to entityframwork
i want to create a login page code, for that i have a database, table with name users(id, password)
and also change/reset password code in c#
Posted
Comments
ZurdoDev 12-Dec-13 8:07am    
There is a significant amount of code to do this. Where are you stuck?

Check this sample application:

Entity Framework for Beginners[^]
 
Share this answer
 
v2
Finaly got the code.
C#
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");

//**************************** For PasswordChange**************************************
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";
//Response.Write(ex);

}
 
Share this answer
 
v2
C#
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");
 
Share this answer
 

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