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.
Please anyone help me to solve this problem.
And Thanks in Advance.
Can you answer this question?
Answer
0 Answers