Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You technically have 3 forums, not two. You close the "inner" form but you never close the "outer" form. The simplest way to fix it is just call <code>Close</code> after you show the dialog for the "inner" form.</p> <pre><code>if (dr.Read()) { if (this.CompareStrings(dr["SCSID"].ToString(), txtUser.Text) &amp;&amp; this.CompareStrings(dr["SCSPass"].ToString(), txtPass.Text) &amp;&amp; this.CompareStrings(dr["isAdmin"].ToString(), isAdmin)) { MessageBox.Show("Hello " + txtUser.Text, "Admin", MessageBoxButtons.OK, MessageBoxIcon.Information); var adminf = new Admin(txtUser.Text); this.Hide(); adminf.ShowDialog(); //This line blocks till you close the form this.Close(); // &lt;--- NEW LINE } else if (this.CompareStrings(dr["SCSID"].ToString(), txtUser.Text) &amp;&amp; this.CompareStrings(dr["SCSPass"].ToString(), txtPass.Text) &amp;&amp; this.CompareStrings(dr["isAdmin"].ToString(), isNotAdmin)) { MessageBox.Show(string.Format("Welcome {0}", txtUser.Text)); var userf = new UserForm(txtUser.Text); this.Hide(); userf.ShowDialog(); //This line blocks till you close the form this.Close(); // &lt;--- NEW LINE } } </code></pre> <hr> <p>On a side note, you really need to be using <a href="https://stackoverflow.com/questions/5468425/how-do-parameterized-queries-help-against-sql-injection">Parametrized Queries</a>. If I decided to try to use the password <code>'; drop table SCSID; --</code> in your login form can you tell me what would happen?</p> <p>You also really should be using <code>using</code> statements around all objects that implement <code>IDisposable</code>. At a quick glance that would be <code>SqlConnection</code>, <code>SqlCommand</code>, and <code>SqlReader</code> but there may be more. Also if you are using a <code>using</code> statment you don't need to call <code>SCScon.Close();</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload