My mysql query in ASP.NET is not running. I have printed out string session so i know i have the value for it and connection string is working in all other methods so i know the issue is not there. Running the command manually in PHPMyadmin works fine. Another method which looks the same, only with select cmd works.
public IActionResult DeleteProfile()
{
string session = HttpContext.Session.GetString("session"); /* gets value (customerid) for user session */
MySqlConnection conn = new MySqlConnection(connectionString);
try
{
conn.Open();
string cmdtxt = "UPDATE customer SET active = '0' WHERE customerid = @session";
MySqlCommand cmd = new MySqlCommand(cmdtxt, conn);
/**************** SQL PARAMETER ********///
MySqlParameter parameter = new MySqlParameter();
cmd.Parameters.AddWithValue("@session", session);
/**************** SQL PARAMETER ********///
}
catch (Exception ex)
{
ViewBag.error = "Connection Error!\n" + ex.Message;
}
finally
{
conn.Close();
ViewBag.error = "Account deleted";
HttpContext.Session.Remove("session");
}
return View("../Account/Index");
}