forum

Home / DeveloperSection / Forums / How to get forget password in ASP.NET 3 tier architecture and stored procedure

How to get forget password in ASP.NET 3 tier architecture and stored procedure

anitha T 1622 03-Jun-2017
Hi sir,I have been designing a project int that i have to write code for forget password i wrote some code and i check that code by putting some debug point.while debugging the password from data base is reading into the data access layer but while leaving the loop from data access layer it showing null.I tried but i couldnt get .here i am giving my code which i tried.

in database my code is:

Create procedure sp_ForgetPwd(
@UserName varchar(20),
@SecurityQuetion varchar(Max) ,
@Answer varchar(Max))
as
begin
select Password from tb_Login where UserName=@UserName And SecurityQuetion=@SecurityQuetion and Answer=@Answer
end

in Presentation layer the code is:

protected void Button1_Click(object sender, EventArgs e)
{
string username = TextBox2.Text;
string securityquestion = DropDownList1.SelectedItem.Text;
string ans = TextBox5.Text;
string pwd = "";

b.Forgetpwd(username, securityquestion , ans, pwd);
Label1.Text = "Your Password is " + pwd;
}

in DAta Access layer the code is:

public string Forgetpwd(string username,string securityquestion ,string ans,string pwd)
{
con.Open();
SqlCommand cmd = new SqlCommand("sp_ForgetPwd", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", username);
cmd.Parameters.AddWithValue("@SecurityQuetion", securityquestion );
cmd.Parameters.AddWithValue("@Answer", ans);
try
{
SqlDataAdapter adapter = new SqlDataAdapter(cmd);

DataSet ds = new DataSet();
adapter.Fill(ds);
SqlDataReader dr = cmd.ExecuteReader();

if (ds.Tables[0].Rows.Count>0)
{
pwd = ds.Tables[0].Rows[0]["Password"].ToString();


}
}
catch (Exception ex)
{
pwd = "";
}
return pwd;
}

in Business layer the code is:

public string Forgetpwd(string username,string securityquestion ,string ans,string pwd)
{
return d.Forgetpwd(username, securityquestion , ans,pwd);
}
Here is the screen shot of Data Access Layer in this the password is retrieving from the data base but the pointer leaves the data access layer and enters into business layer the value of the 'pwd' becomes null.I tried in so many ways but it still giving the same result. 

How to get forget password in ASP.NET 3 tier architecture and stored procedure

Please anyone help me to solve this problem.
And Thanks in Advance.

Updated on 03-Jun-2017

Can you answer this question?


Answer

0 Answers

Liked By