title: C# how do i direct users to different forms based on their role
body: <p>I've connected a SQL database called Data to a windows form application in visual studio C#, the database contains one table called Login.</p>
  
  <p>The table displays like this:</p>
  
  <p><a href="https://i.stack.imgur.com/gYdIJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gYdIJ.jpg" alt="Link to image of my table"></a></p>
  
  <p>Here is image link to how data looks inside my table, so basically I will have Username, Password and Role (I have two types of roles which means user is either Admin or Client):</p>
  
  <p><a href="https://i.stack.imgur.com/vN98L.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vN98L.jpg" alt="Image link to the data in my table"></a></p>
  
  <p>I have made a Login form called Login where users can enter username and password from the database which will take them to a form I've called AdminMenu. I have also made a Form called MenuForm, which I want users whose role is Client to be directed to when they login.</p>
  
  <p>The problem is that I have only made the login so that all users will be directed to the AdminMenu when logging in even if their role isn't Admin. Can someone adapt my code so that users who have the role of Client will be directed to MenuForm when logging in, whereas users that have the role of Admin will be directed to AdminMenu form. </p>
  
  <p>Here's is my code for Login Form:</p>
  
  <pre><code>    private void button2_Click(object sender, EventArgs e)
      {
          this.Close();
      }
  
      private void button3_Click(object sender, EventArgs e)
      {
          SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|Data.mdf;Integrated Security=True");
          SqlDataAdapter sda = new SqlDataAdapter("Select Role from Login Where UserName='" + textBox1.Text + "' and Password='" + textBox2.Text + "'   ",con);
          DataTable dt = new System.Data.DataTable();
          sda.Fill(dt);
          if(dt.Rows.Count == 1)
          {
              this.Hide();
              AdminMenu ss = new AdminMenu();
              ss.Show();
  
          }
  
      }
  
      private void Login_Load(object sender, EventArgs e)
      {
  
      }
  }
  </code></pre>
  
  <p>}</p>