title: How to insert text box value in database on combo box selected item?
body: <p>I designed one login form and in that I used combobox1, textbox1, textbox2 and button. When I select "Admin" in combobox the username and password in textbox1 and textbox2 will checked from Admin table in database if username and password is correct then show the Admin Form.</p>
  
  <p>How can I do this?</p>
  
  <p>Code:</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e) 
  { 
      if (comboBox1.SelectedText == "Admin") 
      { 
          SqlCommand cmd = new SqlCommand("select * from Admin");
          SqlDataReader dr = cmd.ExecuteReader(); 
  
          if (dr.Read()) 
          { 
              textBox1.Text = dr["Username"].ToString(); 
              textBox2.Text = dr["Password"].ToString(); 
              Admin ad = new Admin(); 
              ad.ShowDialog(); 
          } 
      } 
  } 
  </code></pre>