I’m currently facing a trouble when executing the following procedure :
Private Sub PosHistory()
Dim DateFrom As Date = CDate(tsFrom.Text & " 00:00:00")
Dim DateTo As Date = CDate(tsTo.Text & " 23:59:59")
Dim dtList As DataTable
dtList = GetDataTable(ConnString, CommandType.StoredProcedure, "Pos_History", New SqlParameter("@DateFrom", DateFrom), New SqlParameter("@DateTo", DateTo))
.DataSource = Nothing
.DataSource = dtList
DataTable contains approx. 1000 records.
When executing it for the first time, datagridview values are showed instantly.
At the next execution, after having change a parameter value, we must wait for approx. 1 minute to have the result (same amount of records)
Waiting time is during the execution of the line : « .DataSource = dtList »
Does someone have an idea on how to optimize the code so it’s taking the same time as if it was run for the first time ?
Thanks for your help !