Quantcast
Viewing all articles
Browse latest Browse all 3773

Another speed problem

With your last suggestion I was able to speed up the sorting for dates, I also understood how RowComparision works… something I didn’t understand before, and I also understood how to best use PaintCellText. Now I have another problem related to the speed in opening the window. I have this window with a listbox where the data related to the complete invoice are loaded, which however is broken down into two tables (IntestazioneFatturaAcquisti and CorpoFatturaAcquisti). The code is the following:

Var rows As RowSet
Var rows2 As RowSet
Dim StringaConnessione as string

rows=nil
rows2=nil

'If rows <> Nil Then
ListBoxRicerca.HasHeader = True
ListBoxRicerca.HeaderAt(0) = "ID Mittente"
ListBoxRicerca.HeaderAt(1) = "ID CorpoF."
ListBoxRicerca.HeaderAt(2) = "Mittente"
ListBoxRicerca.HeaderAt(3) = "Data Spedizione"
ListBoxRicerca.HeaderAt(4) = "Numero Fattura"
ListBoxRicerca.HeaderAt(5) = "Articolo"
ListBoxRicerca.ColumnCount=6
ListBoxRicerca.ColumnWidths="60,60,150,150,90,200"


if PopupMenu1.RowCount<=0 then
  rows2 = db.SelectSQL("SELECT Ditta FROM IntestazioneFatturaAcquisti GROUP BY Ditta order by Ditta")
  While Not Rows2.AfterLastRow
    PopupMenu1.AddRow(rows2.Column("Ditta").StringValue)
    rows2.MoveToNextRow
  Wend
  rows2.Close
end if


Try
  
  if PopupMenu1.SelectedRowValue="" then  ' NAME of DITTA
    rows2 = db.SelectSQL("SELECT * FROM IntestazioneFatturaAcquisti")
  else
    rows2 = db.SelectSQL("SELECT * FROM IntestazioneFatturaAcquisti Where DITTA='"+PopupMenu1.SelectedRowValue +"'")
  end if
  
  
  While Not Rows2.AfterLastRow
    StringaConnessione="SELECT * FROM CorpoFatturaAcquisti Where ID_IntestazioneFattura="+rows2.column("ID").StringValue+" and  Materiale_Spedito like '%" +Campo1 +"%' and Materiale_Spedito like '%" +Campo2 +"%' order by Materiale_Spedito"
    rows = db.SelectSQL(StringaConnessione)
    While Not Rows.AfterLastRow
      ListBoxRicerca.AddRow(rows2.Column("ID").StringValue,rows.Column("ID").StringValue,rows2.Column("Ditta").StringValue.ConvertEncoding(Encodings.WindowsANSI),rows2.Column("Data").DateTimeValue.SQLDate,rows2.Column("NumeroFattura").StringValue, rows.Column("Materiale_Spedito").StringValue.ConvertEncoding(Encodings.WindowsANSI))
      rows.MoveToNextRow
    wend
    rows2.MoveToNextRow
  Wend
  
  
Catch error As DatabaseException
  MessageBox("Error: " + error.Message)
End Try


me.ListBoxRicerca.Visible=True

Since from my point of view I managed to do the best I could, I wanted to understand if there is a way to speed up the loading of the listbox, because the window takes about 3 seconds to open.

18 posts - 6 participants

Read full topic


Viewing all articles
Browse latest Browse all 3773

Trending Articles