I want to delete a record from data base as a user close the browser. the record which i want to delete is belong to the user who close the browser or log out. I write this code in global but it doesn't work. Can any body help me. Note: I want to delete the record that has username of log outed user. thank you very much the global code:
void Session_End(object sender, EventArgs e)
{
string connStr = ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(connStr);
SqlCommand sqlcmd = new SqlCommand("delete ChatRoomList where UserName=@UserName", sqlconn);
sqlcmd.Parameters.AddWithValue("@UserName", (string)Session["User"]);
sqlconn.Open();
sqlcmd.ExecuteNonQuery();
sqlconn.Close();
}