Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Switching DataSession's
Message
De
13/12/2004 13:22:32
 
 
À
12/12/2004 16:48:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00968641
Message ID:
00968834
Vues:
7
>Hello everybody
>
>Before i start, i know u can switch DS with 'set datasession to' <s>, thats my problem, it's not working as expected.
>
>here is the setup i have:
>
>at app initialization i create an object called 'oToolBox'. this is a class/function container controling the creation and destruction of support functions. at that time this class is empty.
>
>one of my forms started later through menu, has a private datasession. this form now calls a function controlled through the 'oToolBox' like this:
oToolBox.oGlobalStr.GetLogSeekStr(...)
. oToolBox now automaticly creates/attaches an instance of 'oGlobalStr' and executes the method called.
>
>this all works fine, but, since this was called from a form with a private ds, the command
TblName = dbf(AliasName) && the AliasName variable has a valid alias from an open table
does not work. it errors "Alias Not Found".
>
>in the debugger this command executes correctly.
>
>so i added at the begining of my method the following:
>if Type("_screen.ActiveForm.DatasessionId") = "N"
>	CurrentDS		= set("datasession")
>	CallingFormDS	= _screen.ActiveForm.DatasessionId
>	if CallingFormDS <> CurrentDS
>		ResetDS = .t.
>		set datasession to &CallingFormDS
>	endif
>endif
>which also executes all the way through, however the above mentioned command is still throwing the same error. the form in question is active, the table is open with that alias, in the debugger the dbf() shows the correct result - i have no clue, can u not change ds 'on the fly' like this? are there 'easy' alternatives, do i do something wrong?
>
>thanks for all your help in advance!


Hi Gunnar,

Did you make the object as "Custom" or "Session" ? If you create as Session, you can switch the ds-id directly from the object. Please be aware that if this object has a data-bound controls, the controls could lose their data-sources. You can read more in "DataSessionId Property" from VFP help
Define class myClass as Session
    Procedure Set_DS
       This.DataSessionId = _Screen.ActiveForm.DataSessionId

       ** or

       Set DataSession to _Screen.ActiveForm.DataSessionId
    EndProc
EndDefine
Regards
Herman
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform