TIP, cursor life circle

Ruslan Zasukhin sunshine at public.kherson.ua
Mon Aug 23 12:16:37 CDT 2004


On 8/10/04 10:35 AM, "Barney" <barney at custombased.com> wrote:

Hi Barney,

1) I can reproduce problem on your project
    very interesting, because all looks simple.
    I continue debugging.


2) small tip advice.

You have function 

Sub foo

  Dim Pcur as VCursor
  Dim Err as boolean
  Dim S as string
  
  S = Listbox1.cell(listbox1.listindex, 0)
  
  
  
  Pcur = App.DB.SQLSelect(
           "Select * from componants where componant = '" + S + "'", 2,1,2)
  
  If Pcur <> Nil and Pcur.RecordCount > 0 then
    Err = Pcur.deleteAll()
  End if
  
  setupcomp
end



----------------
I recommend to have it as

Sub foo

  Dim Pcur as VCursor
  Dim Err as boolean
  Dim S as string
  
  S = Listbox1.cell(listbox1.listindex, 0)
  
  
  
  Pcur = App.DB.SQLSelect("Select * from componants where componant = '" + S
+ "'", 2,1,2)
  
  If Pcur <> Nil and Pcur.RecordCount > 0 then
    Err = Pcur.deleteAll()
  End if
  
  App.Db.Flush
  pcur = nil
  
  setupcomp

Sub foo




---------------
Because you call function setupcomp() where you again do SQL queries.
But your pCur still exists, and it CAN conflict with your next queries.


So TIP:

* kill cursors AS SOON AS POSSIBLE.

* after modifications it is always good call Flush()




-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list