TDQWERTY
May 1st, 2010, 03:25 PM
I'm experiencing a very slow performance while filling a combobox, is this normal?
I'm reading a db with 78000+ rows, it's indexed in those fields i'm filtering.
Here is the code i'm using:
Dim conn As SqlCeConnection = Nothing
If cmbMarca.SelectedIndex > 0 Then
If cmbMarca.Text = "" Then Exit Sub
Try
conn = New SqlCeConnection("Data Source = " & GetAppPath() & "\DBs\Artigos.sdf")
conn.Open()
Application.DoEvents()
Dim cmd As SqlCeCommand = conn.CreateCommand()
Label1.Visible = True
Cursor.Current = Cursors.WaitCursor
Dim ceda As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT DISTINCT Modelo FROM Artigos WHERE Marca='" & cmbMarca.Text & "' ORDER BY Modelo ASC", conn)
Dim ds As New DataSet
Application.DoEvents()
ceda.Fill(ds, "Modelo")
Application.DoEvents()
cmbModelos.DataSource = ds.Tables("Modelo").DefaultView
Application.DoEvents()
cmbModelos.DisplayMember = "Modelo"
Application.DoEvents()
Cursor.Current = Cursors.Default
Catch err As Exception
MessageBox.Show(err.Message)
Finally
conn.Close()
End Try
End If
Fields "Marca" and "Modelo" are both primary keys :eek2:
It's taking more then 4 minutes to return only 2 values from the database..
I'm reading a db with 78000+ rows, it's indexed in those fields i'm filtering.
Here is the code i'm using:
Dim conn As SqlCeConnection = Nothing
If cmbMarca.SelectedIndex > 0 Then
If cmbMarca.Text = "" Then Exit Sub
Try
conn = New SqlCeConnection("Data Source = " & GetAppPath() & "\DBs\Artigos.sdf")
conn.Open()
Application.DoEvents()
Dim cmd As SqlCeCommand = conn.CreateCommand()
Label1.Visible = True
Cursor.Current = Cursors.WaitCursor
Dim ceda As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT DISTINCT Modelo FROM Artigos WHERE Marca='" & cmbMarca.Text & "' ORDER BY Modelo ASC", conn)
Dim ds As New DataSet
Application.DoEvents()
ceda.Fill(ds, "Modelo")
Application.DoEvents()
cmbModelos.DataSource = ds.Tables("Modelo").DefaultView
Application.DoEvents()
cmbModelos.DisplayMember = "Modelo"
Application.DoEvents()
Cursor.Current = Cursors.Default
Catch err As Exception
MessageBox.Show(err.Message)
Finally
conn.Close()
End Try
End If
Fields "Marca" and "Modelo" are both primary keys :eek2:
It's taking more then 4 minutes to return only 2 values from the database..