Been reading up on the background worker, primarily the doWork method. It stated that this should have the calculations but should not be dependent on GUI code in anyway. This is my function:
void fillLiguanea()
{
// this.liguanea_LaneTableAdapter1.Fill(this.pharmaciesDataSet1.Liguanea_Lane);
try
{
string connectionString = "Data Source=LPMSW09000012JD\\SQLEXPRESS;Initial Catalog=Pharmacies;Integrated Security=True";
SqlConnection con = new SqlConnection(connectionString);
con.Open();
string query = "SELECT * FROM dbo.Liguanea_Lane2";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
string scode = dr.GetString(dr.GetOrdinal("code"));
comboBox2.Items.Add(scode);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Within the above function there is a comboBox entitled: "comboBox2." My question is does that mean I couldn't call my overall above function in the doWork method just because of this comboBox controller?