Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 454
  • Last Modified:

Combo box binding slow - vb.net

Hi guys,

My vb.net application is working very slow while binding combo box.
I am using the following code

      Dim dsCompany As New DataSet
      Dim daCompany As SqlDataAdapter
      conBncclient = New SqlConnection(objbncClient.conClient)
      daCompany = New SqlDataAdapter("SELECT companycode,companyname from qry_syncompanymain order by          companyname", conBncclient)
      daCompany.Fill(dsCompany, "dtCompany")

        If dsCompany.Tables(0).Rows.Count > 0 Then
            cbCompanyname.DataSource = dsCompany.Tables("dtCompany")
            cbCompanyname.DisplayMember = "companyname"
            cbCompanyname.ValueMember = "companycode"
            cbCompanyname.SelectedIndex = -1
        End If

Am i doing anything wrong?. There are around 8000 records in the table and it takes 4-5 seconds to bind the combo box.
Please help.



  • 2
2 Solutions
I wonder if there could be any improvement in the code so that it takes less time. DataAdapters are a little faster but then if you need a dataset, you can do without it.
If it takes 4-5 secs just to bind, I mean if you take the Time Difference between the lines of codes for databinding then yes it is taking some time.
But if it is 4-5 secs for the whole process of creating and filling the dataset from the database and binding the combo, GUI display and all included. Then I think its fair enough.

Brian CroweDatabase AdministratorCommented:
If the combobox is readonly then i would recommend a datareader instead of a dataadapter...they're faster.
I am sorry in the above post I meant datareader only, he is already using a DataAdapter....

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now