#619

Claudius Sailer Claudius at sailer-online.de
Mon May 9 17:53:49 CDT 2005


Am 09. Mai 2005 um 10:31 Uhr schrieb Ruslan Zasukhin:

> On 5/9/05 7:21 AM, "Claudius Sailer" <Claudius at sailer-online.de>  
> wrote:
>
> Hi Claudius,
>
>
>> Hello Again :-))
>>
>> I believe I found problem of #619. I didn't set Cursor=NIL before I
>> reuse it for new SQLSelect. Could you please verify that?
>>
>
> Please tell me again,
>
> So you have not delete cursor and what happens:
>     - next cursor cause crash?
>     - or some error ?
>     - or ... ?
>
> Expected behavior is error as:
>     cursor cannot be built because record(s) are locked

 From PopupMenu I can choose accounts. This accounts are stored in a  
cursor made in this window as global, because I am using this cursor  
from several Events and methods. In one method I fill ListBox. You  
can see coding. When I have choosen Accounts with more then 3000  
records application crashes after 3rd call of LisfboxFilling method  
at this moment where cursor (CurBuchungen=V4RBSQLSelect 
(meineDatenbank,SQLString) is build. When I choose smaller accounts  
it takes much more time until application crashes. Now I inserted one  
new row of code

CurBuchungen=NIL and the problem is gone.

In V4RB 1.x I never had this problem. don't aks me why, but now it is  
fixed and everything is fine.


   SQLString=SQLBuilder(33,false,cstr(AktuellesKonto))

   CurBuchungen=V4RBSQLSelect(meineDatenbank,SQLString)
   Ende=CurBuchungen.RecordCount
   L=ListBox1
   PagePanel1.value=1
   ListBox1.FillingProzess=true
   L.DeleteAllRows
   L.addrow ""
   NeueZeile=L.LastIndex
   L.cell(NeueZeile,1)="Anfangssaldo"
   SaldoCalc=HauptKontoStartBetrag
   L.cell(NeueZeile,5)=format(SaldoCalc,FormatZahlNegativ)
   //Cursordefinitionen fuer Performance
   string1=CurBuchungen.StringField(2) //BDatum
   string2=CurBuchungen.StringField(3) //Gegenkonto
   string3=CurBuchungen.StringField(4) //Kategorie
   string4=CurBuchungen.StringField(7) // Kommentar
   Ein=CurBuchungen.LongField(6) //Einnahme
   Aus=CurBuchungen.LongField(5) //Ausgabe

   //ListBox fuellen
   For i=1 to Ende
     CurBuchungen.Position=i
     L.addrow string1.GetString
     NeueZeile=L.LastIndex
     L.cell(NeueZeile,1)=string2.GetString'ZielKonto
     L.cell(NeueZeile,2)=string3.GetString
     if Aus.value<>0 then
       Betrag=Aus.value/100
       L.cell(NeueZeile,3)=format(Betrag,FormatZahlNegativ)
       SaldoCalc=SaldoCalc-Betrag
     else
       Betrag=Ein.value/100
       L.cell(NeueZeile,4)=format(Betrag,FormatZahlNegativ)
       SaldoCalc=SaldoCalc+Betrag
     end if
     L.cell(NeueZeile,5)=format(SaldoCalc,FormatZahlNegativ)
     L.cell(NeueZeile,6)=string4.GetString
     if i mod Teiler = 0 then
       ProgressBar1.value=ProgressBar1.value+Teiler
     end if
   next



>> When you say now YES I will have a lot of work to set all cursors to
>> NIL in my coding.
>
> Note, if you create cursor inside of function, then on exit of  
> function
> cursor will be deleted automatically by REALbasic.
>
>     func foo()
>         dim curs as VCursor
>
>         curs = db.SqlSelect()
>
>         // work
>
>         curs = nil  // optional
>     end
>
> But if you create several cursors inside of single function,
> Or if you keep pointer to cursor in some class or global variables  
> then keep
> your eye.

normally Corsur are only created window wide because this window is  
only open and closed and cursor is only used one time, or I use  
cursor in functions. so I only have this problem at one time where I  
need a global Cursor.

thanks for help


Claudius

-- 
G4/733 QS / MacOS X 10.4de / RB 5.5.3de/ Valentina 1.10.0 & 2.0.3
Homepage    http://www.ClaSai.de
iChat        ryhoruk
RealBasic ListBoxes: [ I feel the need...the need for speed!!! ]



More information about the Valentina mailing list