private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Grups g = new Grups(); g.OpenConnection(connectionString); int idgr = g.GetIdByNzach(nzach); g.CloseConnection(); Predmets p = new Predmets(); p.OpenConnection(connectionString); int idprd = p.GetIdByName(comboBox1.Text); p.CloseConnection(); Marks m = new Marks(); m.OpenConnection(connectionString); dataGridView1.DataSource = m.GetMarksByGroupAndPredmet(idgr, idprd); m.CloseConnection(); }