Skip to content

Instantly share code, notes, and snippets.

@mrichman
Created May 18, 2010 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrichman/405018 to your computer and use it in GitHub Desktop.
Save mrichman/405018 to your computer and use it in GitHub Desktop.
public override void RemoveItem(HttpContext context,
string id,
object lockId,
SessionStateStoreData item)
{
var conn = new MySqlConnection(connectionString);
var cmd = new MySqlCommand("DELETE FROM sessions WHERE SessionId = ?SessionId AND ApplicationName = ?ApplicationName AND LockId = ?LockId", conn);
cmd.Parameters.Add("?SessionId", MySqlDbType.VarChar, 80).Value = id;
cmd.Parameters.Add("?ApplicationName", MySqlDbType.VarChar, 255).Value = ApplicationName;
cmd.Parameters.Add("?LockId", MySqlDbType.Int32).Value = lockId;
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch (MySqlException e)
{
if (WriteExceptionsToEventLog)
{
WriteToEventLog(e, "RemoveItem");
throw new ProviderException(exceptionMessage);
}
else
throw e;
}
finally
{
conn.Close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment