You are on page 1of 2

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

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); } }

You might also like