---
title: "How to get forget password in ASP.NET 3 tier architecture and stored procedure"  
description: "How to get forget password in ASP.NET 3 tier architecture and stored procedure"  
author: "anitha T"  
published: 2017-06-03  
updated: 2017-06-03  
canonical: https://www.mindstick.com/forum/34303/how-to-get-forget-password-in-asp-dot-net-3-tier-architecture-and-stored-procedure  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# How to get forget password in ASP.NET 3 tier architecture and stored procedure

Hi sir,I have been designing a [project](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects) int that i have to write code for forget [password](https://www.mindstick.com/blog/118/retriving-user-password-by-using-stored-procedure-in-asp-dot-net) i wrote some code and i check that code by putting some debug point.while [debugging](https://www.mindstick.com/blog/393/javascript-debugging) the password from data base is [reading](https://www.mindstick.com/articles/126273/books-commonly-found-on-college-reading-lists) into the [data access](https://www.mindstick.com/blog/301551/risks-and-challenges-of-data-access-and-sharing) 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](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) my code is:**\
\

```
Create procedure sp_ForgetPwd(@UserName varchar(20),@SecurityQuetion varchar(Max) ,@Answer varchar(Max))asbeginselect Password from tb_Login where UserName=@UserName And SecurityQuetion=@SecurityQuetion and Answer=@Answerend
```

\
**in [Presentation layer](https://answers.mindstick.com/blog/23/drile-down-about-the-presentation-layer-in-osi-model) 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](https://www.mindstick.com/articles/12213/how-to-start-a-jewellery-making-business-online-business-ideas) 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](https://www.mindstick.com/articles/11/pointers) 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](https://www.mindstick.com/mindstickforums/fa40c963-a6ce-4618-b307-f755120b9406/images/f80693b5-da3a-40c5-b266-c1fc94b48db5.png)\
\
Please anyone help me to solve this problem.\
And Thanks in Advance.\


---

Original Source: https://www.mindstick.com/forum/34303/how-to-get-forget-password-in-asp-dot-net-3-tier-architecture-and-stored-procedure

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
