Combo Box loading speed

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

I have a pair of databound combo boxes on my page. I am
quite unhappy with the time it takes to load them. Is
there a way to speed it up by coding it manually or
is .datasource, .valuemember .displaymember the best?

Thanks,
Aaron
 
I guess I forgot to ask you on how many records in the
table you're retreiving records from, but regardless make
sure that you have indexes on the fields you using in the
where clause.

-Alex
 
Use a datareader, much much faster!

Private Function PopulateCombo1()

sbStatbar.Text = "Loading Comment Defaults"
sbStatbar.Refresh()

Dim strSQL As String = "Select Col1 FROM Table"
Dim cmdSelect As SqlCeCommand = New SqlCeCommand(strSQL,
MasterDBconnection)
cmdSelect.CommandType = CommandType.Text

Try
Dim dtr As SqlCeDataReader = cmdSelect.ExecuteReader
(CommandBehavior.Default)
While (dtr.Read()) ' Populate Comment type combo
cmbCombo1.Items.Add(dtr.GetString(0))
End While
dtr.Close()
dtr.Dispose()

Catch ex As SqlCeException
SQLCEFuncErrorName(ex)
End Try

sbStatbar.Text = "Combo Loaded."
sbStatbar.Refresh()

End Function
 
Back
Top