Skip to content

Instantly share code, notes, and snippets.

@mrichman

mrichman/gist:405018

Created May 18, 2010
Embed
What would you like to do?
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