private void button2_Click(object sender, EventArgs e) { for (int i = 0; i < dataGridView1.Rows.Count; i++) { MySqlConnection con = new MySqlConnection(@"Data Source=localhost; Database=nigol; User ID=**; Password=**"); MySqlCommand cmd = new MySqlCommand("INSERT INTO masterlist (PROBER_ID,IP_ADDRESS,LEVEL) values (@PROBER_ID,@IP_ADDRESS,@LEVEL)", con); //string InsertString = @"IF NOT EXISTS (SELECT * FROM from nigol.masterlist WHERE PROBER_ID, IP_ADDRESS, LEVEL = @PROBER_ID, @IP_ADDRESS, @LEVEL)"; cmd.Parameters.AddWithValue("@PROBER_ID", dataGridView1.Rows[i].Cells[0].Value); cmd.Parameters.AddWithValue("@IP_ADDRESS", dataGridView1.Rows[i].Cells[1].Value); cmd.Parameters.AddWithValue("@LEVEL", dataGridView1.Rows[i].Cells[2].Value); con.Open(); cmd.ExecuteNonQuery(); con.Close(); { progressBar1.Maximum = dataGridView1.Rows.Count; progressBar1.Value = i; } } }
// before the for loop progressBar1.Maximum = dataGridView1.Rows.Count; for (int i = 0; i < dataGridView1.Rows.Count; i++) { // your code.. } // after the for loop if(progressBar1.Value == dataGridView1.Rows.Count - 1) { MessageBox.Show("Ta Da!"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)