'MessageBox show twice c#
I don't have any idea why is messagebox appearing twice in exit event Here's my code:
private void dashboard_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult dr = new DialogResult();
dr = MessageBox.Show("Are you sure you want to close the application?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
ConnectionString.conn.Open();
SqlCommand cmd = new SqlCommand("delete from user_session_tbl where SESSION_ID = '" + Global_Variables.id + "'", ConnectionString.conn);
cmd.ExecuteNonQuery();
ConnectionString.conn.Close();
MessageBox.Show("Goodbye " + Global_Variables.fname + " Have a nice Day!", "Message", MessageBoxButtons.OK, MessageBoxIcon.None);
Application.Exit();
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
