Hi,
Try adding this when login is successful:
if (dr.HasRows == true)
{
MessageBox.Show("Login Successfull", "Login Information");
this.Hide();
MyWinForm1 M1 = new MyWinForm1();
M1.Show();
}
While closing the file handle the form closing event as I said in my comments below. Use this:
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if(MessageBox.Show("Do you want to save changes to your text?", "My Application",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
e.Cancel = true;
Application.Exit();
}
}
All the best.
--Amit