I have this code so far for a background worker that will run the background worker:
if (backgroundWorker1.IsBusy == true)
{
backgroundWorker1.CancelAsync();
}
else
{
backgroundWorker1.RunWorkerAsync();
}
Will this close out the connection in the backgrounder worker as well? Or do I need to add lines of code for the progress change?
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
try
{
superset = new DataSet();
connectionString = "Driver={IBM DB2 ODBC DRIVER}; Database=" + lines[i] + "; Hostname=" + lines[i] + "." + lines[i] + ".XXX; Port = XXXX; Protocol = TCPIP; Uid=XX; Pwd= XXXX;
}
connection = new OdbcConnection(connectionString);
adapter = new OdbcDataAdapter(masterquery, connection);
connection.Open();
adapter.Fill(superset);
superset.Merge(superset);
connection.Close();
}
}
dataGridView1.DataSource = superset;
dataGridView1.DataSource = superset.Tables[0];
//tabControl1.SelectedTab = tabPage3;
}