mazhar  khan

mazhar khan

  • 1.6k
  • 148
  • 4.2k

I am getting problem with stored procedure

May 2 2015 8:18 AM
create procedure Get_ResetPassword
(
@Userid varchar(300),
@UniqueCode varchar(100)
)
as
begin
select Email,UniqueCode from Table_login where UniqueCode=@UniqueCode and Email=@Userid
end


create procedure Update_ResetPassword
(
@Userid varchar(300),
@Password varchar(50),
@UniqueCode varchar(100)
)
as
begin
update Table_login set UniqueCode='',Password=@Password where UniqueCode=@UniqueCode and Email=@Userid

end
 
 
 
USE [Dangote]
GO
/****** Object: StoredProcedure [dbo].[Get_ForgotPassword] Script Date: 05/02/2015 17:41:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Get_ForgotPassword]
(
@Userid varchar(100)

)
as
begin

select * from Table_login where Email=@Userid
end
 
 
USE [Dangote]
GO
/****** Object: StoredProcedure [dbo].[Update_ForgotPassword] Script Date: 05/02/2015 17:41:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER procedure [dbo].[Update_ForgotPassword]
(
@Userid varchar(100),
@uniqueCode varchar(100)
)
as
begin
update Table_login set UniqueCode=@uniqueCode where Email=@Userid
end 
 
 
 
  public int Get_ForgotPassword(BusinessObject bo)
{


int n = 0;

ConnectMethod();

cmd = new SqlCommand("Get_ForgotPassword", con);

//try
//{
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.AddWithValue("@Userid", bo.Para1);

n = Convert.ToInt32(cmd.ExecuteNonQuery());
return n;
//}


//catch (Exception ex)
//{

// return n;

//}
//finally
//{
// con.Close();
// con.Dispose();
// cmd.Dispose();
//}

}


public int Update_ForgotPassword(BusinessObject bo)
{

int n = 0;
ConnectMethod();
cmd = new SqlCommand("Update_ForgotPassword", con);

//try
//{

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Userid", bo.Para1);
cmd.Parameters.AddWithValue("@uniqueCode", bo.Para3);
n = cmd.ExecuteNonQuery();
return n;
//}


//catch (Exception ex)
//{

// return n;

//}
//finally
//{
// con.Close();
// con.Dispose();
// cmd.Dispose();
//}


}
 
 
public int Get_ForgotPassword(BusinessObject bo)
{

return data.Get_ForgotPassword(bo);

}


public void Update_ForgotPassword(BusinessObject bo)
{

if (data.Get_ForgotPassword(bo) == -1)
{

bo.Para3 = Convert.ToString(System.Guid.NewGuid());

StringBuilder strBody = new StringBuilder();


MailAddress from = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["AdminFromEmailAddress"].ToString());
MailAddress to = new MailAddress(bo.Para1);
MailMessage message = new MailMessage(from, to);
message.IsBodyHtml = true;
strBody.Append("<a href=http://localhost:2464/SampleApplication/ResetPassword.aspx?emailId=" + bo.Para1 + "&uCode=" + bo.Para3 + ">Click here to change your password</a>");

SmtpClient client1 = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SmtpClientclientPath"].ToString());
client1.Port = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientclientPathPort"].ToString());
client1.Send(message);



}

}
 
bo.Para1 = txt_Email.Text;

bl.Update_ForgotPassword(bo); 
 
 
 
 
 
 
 
 
 

Answers (1)