Hello guyz. In this code show you on how to use the progress bar with Insert command.
First Step:
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "your connectionstring";
conn.Open();
int i;
int x = 1000; //insert 1000 rows
Bar.Maximum = x; //Bar ( Your progressbar)
for (i = 0; i < x; i++)
{
string sQL = "Insert Into table1" & _ "(empid,dates,username) values ('COLLADO','11/4/1982','Sayre')";
OleDbCommand cmd = new OleDbCommand(sQL, conn);
cmd.ExecuteNonQuery();
Bar.Value = Bar.Value + 1;
pr = Bar.Value;
pr1 = pr / x;
pr2 = pr1 * 100;
lblpercent.Text = pr2.ToString(); //show the percent in label
Application.DoEvents();
}
//Get the total row in the table
string sQL1 = "select * from table1";
OleDbCommand cmd1 = new OleDbCommand(sQL1, conn);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd1);
da.Fill(ds);
string ss = ds.Tables[0].Rows.Count.ToString();
Wednesday, June 25, 2008
Subscribe to:
Posts (Atom)