Ok so I have a class called DBdatabase.cs which stored all my sql queryies, what I am trying to do is execute an update statement that updates the users password through the session however when I execute the statement nothing occurs what am I doing wrong?
Also Please note that the update statment does work when I have the sql statment in ChangePassword.aspx.cs as I declare the session state in the sql statment like this 'Session["LoginSession1"]'.
Code below:
DBdatabase.cs
public static void ChangePasswordParent(string password, object session)
{
cmd = new SqlCommand("UPDATE Users SET Password ='" + password + "' WHERE Username = '" + session + "'", con);
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine("Exception in DBHandler", ex);
}
finally
{
con.Close();
}
}
Changepassword.aspx.cs
if (Session["LoginSession"] != null)
{
string a = TextBox3.Text;
object b = Session["LoginSession1"];
DBdatabase.ChangePasswordParent(a,b);
Label4.Text = "Password Changed";
this.Label4.ForeColor = Color.Green;
}