I HAVE BEEN WORKING ON THIS CHANGE OF PASSWORD CODE FOR A WHILE NOW AND IT HAS BEEN GIVEN ME ALOT OFF ISSUES.
CAN SOMEONE PLEASE HELP ME OUT , PLEASE CHECK THE CODE BELOW.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Changepassword : System.Web.UI.Page
{
CRMDataClassesDataContext db = new CRMDataClassesDataContext();
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str = null;
SqlCommand com;
byte up;
protected void btn_update_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from Login ";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
if (txt_cpassword.Text == reader["PasswordX"].ToString())
{
up = 1;
}
}
reader.Close();
con.Close();
if (up == 1)
{
con.Open();
str = "update login set Password=@Password where UserName='" + Session["UserName"].ToString()+ "'";
com = new SqlCommand(str, con);
com.Parameters.Add(new SqlParameter("@PasswordX", SqlDbType.VarChar, 50));
com.Parameters["@PasswordX"].Value = newpasstxt.Text;
com.ExecuteNonQuery();
con.Close();
MessageLabel.Text = "Password changed Successfully";
}
else
{
MessageLabel.Text = "Please enter correct Current password";
}
}
}
THANKS.
CAN SOMEONE PLEASE HELP ME OUT , PLEASE CHECK THE CODE BELOW.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Changepassword : System.Web.UI.Page
{
CRMDataClassesDataContext db = new CRMDataClassesDataContext();
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str = null;
SqlCommand com;
byte up;
protected void btn_update_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from Login ";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())
{
if (txt_cpassword.Text == reader["PasswordX"].ToString())
{
up = 1;
}
}
reader.Close();
con.Close();
if (up == 1)
{
con.Open();
str = "update login set Password=@Password where UserName='" + Session["UserName"].ToString()+ "'";
com = new SqlCommand(str, con);
com.Parameters.Add(new SqlParameter("@PasswordX", SqlDbType.VarChar, 50));
com.Parameters["@PasswordX"].Value = newpasstxt.Text;
com.ExecuteNonQuery();
con.Close();
MessageLabel.Text = "Password changed Successfully";
}
else
{
MessageLabel.Text = "Please enter correct Current password";
}
}
}
THANKS.