I m trying update password in database using asp.net with c#.
I have three text box in my aspx page
Old password
New password
confirm password
i m using following code but its not resolving
step1 - this code in aspx.cs page
Expand|Select|Wrap|Line Numbers
- protected void btnchangepwd_Click(object sender, EventArgs e)
- {
- try
- {
- if (IsValid)
- {
- SqlCommand cmd = new SqlCommand("HMSFetchPassword", con);
- cmd.CommandType = CommandType.StoredProcedure;
- SqlDataReader dr;
- con.Open();
- cmd.Parameters.Add("@Pwd", this.txtoldpass.Text);
- dr = cmd.ExecuteReader();
- if (dr.Read()==null)
- {
- if(txtoldpass.Text==txtnewpass.Text)
- {
- cmd.CommandText="HMSSP_UpdatePassword";
- cmd.CommandType=CommandType.StoredProcedure;
- cmd.Parameters.Add("@Pwd",this.txtoldpass.Text);
- // cmd.ExecuteNonQuery();
- lblmessage.Visible=true;
- lblmessage.Text="Your Password Sucessfully changed.";
- }
- else
- {
- lblmessage.Visible = true;
- lblmessage.Text = "Please enter correct Password ";
- }
- dr.Close();
- con.Close();
- }
- }
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- }
- }
step-2
Expand|Select|Wrap|Line Numbers
- CREATE procedure [dbo].[HMSSP_FetchPwd]
- (
- @Name varchar(200)
- )
- As
- SET NOCOUNT ON
- begin
- select Pwd from TblHMSOwner_Reg where Name=@Name
- End
- create procedure [dbo].[HMSSP_UpdatePassword]
- (
- @Name Varchar(50),
- @Pwd Varchar(50)
- )
- As
- SET NOCOUNT ON
- begin
- update TblHMSOwner_Reg
- set Pwd=@Pwd where Name=@Name
- End
hi if anyone have idea about it or have code then please help me
thanks in advance