Results 1 to 2 of 2

Thread: [RESOLVED] Slow performance using SqlCeDataAdapter.Fill

  1. #1

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Resolved [RESOLVED] Slow performance using SqlCeDataAdapter.Fill

    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:

    Code:
    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

    It's taking more then 4 minutes to return only 2 values from the database..
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  2. #2

    Thread Starter
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: Slow performance using SqlCeDataAdapter.Fill

    My bad, i forgot to create the indexes:
    Here is the solution:

    CREATE INDEX idMarcas ON Artigos (Marca)
    CREATE INDEX idModelos ON Artigos (Modelo)
    CREATE INDEX idArtigo ON Artigos (Artigo)
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width