I have made a method and i wanted it to put it on Backgroundworker with a progressbar in it. this is the first that im working on a Background worker.
here is my Code:
public void WorkLoad()
{
string conStr, sheetName;
conStr = string.Empty;
//Get the name of the First Sheet.
using (OleDbConnection kuneksyon = new OleDbConnection(Excel07ConString))
{
using (OleDbCommand utos = new OleDbCommand())
{
using (OleDbDataAdapter oda = new OleDbDataAdapter())
{
utos.Connection = kuneksyon;
kuneksyon.Open();
DataTable dtExcelSchema = kuneksyon.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
kuneksyon.Close();
DataTable dt = new DataTable();
utos.Connection = kuneksyon;
utos.CommandText = "SELECT [Engineer],[SITEID],[SITE NAME],[2G TX Status],[3G TX Status],[WO Status-LTE] From [" + sheetName + "]";
kuneksyon.Open();
oda.SelectCommand = utos;
oda.Fill(dt);
kuneksyon.Close();
//Populate DataGridView.
ForIssuanceView.DataSource = dt;
ForIssuanceView.Columns.Add(" ", " ");
}
}
}
}