Link to home
Start Free TrialLog in
Avatar of inetworks
inetworks

asked on

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.

Thanks,

Anish

Avatar of arif_eqbal
arif_eqbal

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.


ASKER CERTIFIED SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial