Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataSession troubles.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00457954
Message ID:
00459014
Views:
28
>>Since a GRID or perhaps a Combo may be refreshed anytime, using SET
>>DATASESSION TO is risky, whether you set it back or not. Why not just let VFP
>>do all this natively? Create a session object. Ask it to create anything you
>>desire.
>
>Sarek mumbles something about damned idiots writing KB articles before
>thinking the implications through....

Here, this is better....

Class:
DEFINE CLASS myPrivateDSClass AS session

PROCEDURE UseTable
    *!* By using the table inside a method of the session object,
    *!* you are working in the object's DataSession
    LPARAMETER tcTable
       
    IF NOT USED(tcTable)
        USE (tcTable) IN 0
    ENDif
ENDproc

PROCEDURE Destroy
    CLOSE DATA ALL
ENDproc
Test code:
CREATE TABLE myDSTest (cTest C(10))
USE DBF() SHARED
*!* CREATE TABLE makes an exclusively-used table. USE DBF() SHARED is
*!* a good method for not having to remember the path to the table
FOR i = 1 TO 10
   INSERT INTO myDSTest ;
      VALUES (TRANSFORM(i))
ENDfor

oDS = NEWOBJECT("myPrivateDSClass", "MyDS.prg")    
*!* NEWOBJECT allows you to specify a class in a program or other 
*!* location without the use of SET CLASSLIB TO ... ADDITIVE.
oDS.UseTable("myDSTest")
SET

*!* The following line is needed to keep oDS in scope, so you can
*!* see the datasession.
SUSPEND
My blog
My consulting page
My home page

Member of the Trim Your Auto-Quote Campaign!
What's another word for thesaurus?
Previous
Reply
Map
View

Click here to load this message in the networking platform