Fox Tables in AVFP

Topics: Developer Forum, User Forum
Jan 9, 2014 at 10:42 PM
Hi Friends,

Just wondering what your thoughts are on managing your fox tables. Do you open and close them in each method or do you open it if it's not open and leave it open for the next method call?

AVFP Rocks!

Tom
Coordinator
Jan 10, 2014 at 10:31 AM
Tom,

I leave them open. Faster performance and I don't see any reason to close them.
Jan 10, 2014 at 10:45 AM
Thanks for the advice Claude I appreciate it. Best, Tom  On Jan 10, 2014, at 05:31 AM, claudefox wrote: > From: claudefox > Tom, > > I leave them open. Faster performance and I don't see any reason to close them. > > Read the full discussion online. > > To add a post to this discussion, reply to this email ([email removed]) > > To start a new discussion for this project, email [email removed] > > > You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com. > > Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Thanks for the advice Claude I appreciate it.

Best,

Tom

Sep 15, 2015 at 11:34 AM
Hi Claude/All,

I have the following method in my class to keep VFP tables open.
PROCEDURE GetRecords
    LPARAMETERS pResultSet, pTable, tlKeepOpen

    LOCAL lcCursor, lcAlias, cExpr, lRetValue

    lRetValue = .T.
    lcCursor = "V_"+SYS(3)
    lcAlias = UPPER(JUSTSTEM(pTable))
    
    pResultSet = UPPER(IIF(EMPTY(pResultSet),lcCursor,pResultSet))
    USE IN SELECT(pResultSet)
    
    IF !USED(lcAlias)
       SELECT 0
       USE (pTable) ALIAS (lcAlias) SHARED
       =STRTOFILE(CHR(13)+CHR(10)+ [User : ]+ SYS(0)+ [ - ]+ pTable+ [ table open as ]+ lcAlias+ [ as keep open is set to ]+ TRANSFORM(tlKeepOpen)+ [ ]+ TIME(),[C:\Temp\Hello.Txt],1)
    ENDIF

    SELECT (lcAlias)
    
    cExpr = [SELECT * FROM ] + lcAlias+ [ INTO CURSOR ]+ pResultSet
    
    &cExpr

    IF !tlKeepOpen
         USE IN SELECT(lcAlias)
    ENDIF
if I run this code from vfp on my machine, it opens the table and then keep it open for the next calls.

But If I run this code from avfp through IIS, It opens the table multiple times on the server machine which I can see from "Mange Open Files" from windows server, opend by <my machine name>$ and log following messages in the text file as

User : <myDesktopName> # DefaultAppPool - <networkshare\tablename.DBF table open as <aliasname> as keep open is set to .T. 15:11:16
User : <myDesktopName> # DefaultAppPool - <networkshare\tablename.DBF table open as <aliasname> as keep open is set to .T. 15:11:16
User : <myDesktopName> # DefaultAppPool - <networkshare\tablename.DBF table open as <aliasname> as keep open is set to .T. 15:11:16

1) How can I open the vfp table only once ? Is there any session variable/setting I need to declare ?

2) In case of closing all vfp tables (if required later), How can I get open tables list like aused() ?

Regards,
Naeem
Coordinator
Sep 15, 2015 at 2:18 PM
Edited Sep 15, 2015 at 2:19 PM
Remember that every request sent to IIS/AVFP would be handled with a separate instance of AVFP server (a separate thread, really, on the same server, but a clear environment for all tense and porpoises). Also, remember that web apps are asynchronous and stateless. So, open your dbf files in "one central point" so they are pre-opened and ready to be used in AVFP requests makes no sense. Think in your AVFP code as a snippet that is called, rans and then ends, so any time you call it you have to setup your whole environment (SETs, open files, load libraries, etc)... but this happens really fast!!

Victor