private void button1_Click(object sender, EventArgs e) { ConnClass oConexion = new ConnClass(); string usuario = this.txtUsername.Text.Trim(); string contra = this.txtPassword.Text.Trim(); string comando = "SELECT Count(*) FROM usuarios where UsuarioName = '" + usuario + "' and Password = '******'"; if (oConexion.Count(comando) == 1) { FormPrincipal principal = new FormPrincipal(); principal.Show(); //se le otorga como propietario del formulario a Login this.Owner = principal; this.Hide(); } else { MessageBox.Show("Usuario o Password no coinciden"); } }