R
RvGrah
This code:
private void GetPlans(){
dt = dt.Clone(); //New object?
cn.Open();
SqlDataReader drd = cmdGetPlans.ExecuteReader();
if (drd.HasRows){
while (drd.Read()){
dt.Rows.Add(new Object[] {drd["JobID"].ToString(),//where the problem
happens
drd["CustName"].ToString()});
}
}
cn.Close();
}
Works instantly, but this code (Only the second line is different):
private void GetPlans(){
dt.Rows.Clear();
cn.Open();
SqlDataReader drd = cmdGetPlans.ExecuteReader();
if (drd.HasRows){
while (drd.Read()){
dt.Rows.Add(new Object[] {drd["JobID"].ToString(),
drd["CustName"].ToString()});
}
}
cn.Close();
}
Takes an eternal seeming 1.75 seconds to fill the first row the 2nd
time it's called.
Behavior is the same if I use a SqlDtaAdapter and DataSet. Only the
second time is that slow, the first call and all subsequent calls are
virtually instantaneous.
dt is a DataTable and is bound to a ComboBox(this is a critical part of
the problem) The sitution is the same databinding a dataset table to a
listbox, combobox or other like objects, or even just adding them from
a sqldatareader manually.
Can anyone tell me why?
TIA Bob Graham
private void GetPlans(){
dt = dt.Clone(); //New object?
cn.Open();
SqlDataReader drd = cmdGetPlans.ExecuteReader();
if (drd.HasRows){
while (drd.Read()){
dt.Rows.Add(new Object[] {drd["JobID"].ToString(),//where the problem
happens
drd["CustName"].ToString()});
}
}
cn.Close();
}
Works instantly, but this code (Only the second line is different):
private void GetPlans(){
dt.Rows.Clear();
cn.Open();
SqlDataReader drd = cmdGetPlans.ExecuteReader();
if (drd.HasRows){
while (drd.Read()){
dt.Rows.Add(new Object[] {drd["JobID"].ToString(),
drd["CustName"].ToString()});
}
}
cn.Close();
}
Takes an eternal seeming 1.75 seconds to fill the first row the 2nd
time it's called.
Behavior is the same if I use a SqlDtaAdapter and DataSet. Only the
second time is that slow, the first call and all subsequent calls are
virtually instantaneous.
dt is a DataTable and is bound to a ComboBox(this is a critical part of
the problem) The sitution is the same databinding a dataset table to a
listbox, combobox or other like objects, or even just adding them from
a sqldatareader manually.
Can anyone tell me why?
TIA Bob Graham