I have this function that calls the function:
private void liguaneaRxToolStripMenuItem_Click(object sender, EventArgs e)
{
FillLiguanea();
}
This is the function it invokes:
private 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());
}
}
It's over 5000+ data reading in from the SQL database, but a 20 second lag each time before it reads in will not be satisfying to the end user.
My question is why does this happen and is there a way to speed it up?