private void button3_Click(object sender, EventArgs e) { for (int i = 0; i < dataGridView1.Rows.Count; i++) { string nn = dataGridView1.Rows[i].Cells["matricule"].Value.ToString(); db_connection(); MySqlCommand cmd = new MySqlCommand(); string query = "SELECT mat,dnd FROM test where mat='" + nn + "'"; cmd.Connection = connect; DataSet ds = new DataSet(); using (MySqlDataAdapter adapter = new MySqlDataAdapter(query, conn)) { while(adapter != null){ adapter.Fill(ds); if (ds.Tables[0].Rows.Count != 0) { DataGridViewColumn col = new DataGridViewTextBoxColumn(); col.HeaderText = ds.Tables[0].ToString(); int colIndex = dataGridView2.Columns.Add(col); //dataGridView2.DataSource = ds.Tables[0]; } } } } int count = dataGridView2.Rows.Count; label6.Text = count.ToString(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)