Click here to Skip to main content
16,004,653 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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;            
                }
                            
            }
    }
Posted
Updated 3-Nov-15 15:12pm
v2

1 solution

C#
// 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!");
}


[Edit]
put double =
:sigh:

-KR
 
Share this answer
 
v3
Comments
Nigol_Learner 4-Nov-15 0:37am    
Thanks Bro...Great
Krunal Rohit 4-Nov-15 1:01am    
Glad I could help.

-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900