Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Private Datasession for programs
Message
 
 
À
16/02/2006 13:28:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01096829
Message ID:
01096841
Vues:
13
>Hello,
>
>Does anyone know if you can create a datasession within a program, for the tables used in the program to open in?
>
>Rich

Here is what we use:
***** Class definition for private session
define class PrivateSession as session
* Previous data session ID
	nPriorDataSession = set('DATASESSION')
* Status Bar settings
	cOldStatusBar = set('status bar')

	procedure init
	lparameter tnPriorDataSession

*--- scoped to data session...
	set deleted on
	set century on
	set talk off
	set exclusive off
	set multilocks on
	set exact on
	set ansi on
	set near off
	set safety off
	if not empty(m.tnPriorDataSession)
		this.nPriorDataSession = m.tnPriorDataSession
	endif
	if type("m.goApp.oDatabaseMgr") = "O"
		local lcDbcName
		lcDbcName = m.goapp.oDatabaseMgr.GetFullyQualifiedDatabase()
		if !empty(m.lcDbcName)
			open database (m.lcDbcName)
			set database to (m.lcDbcName)
		else
			open database mmviscollect
			set database to mmviscollect
		endif
	else
		if vartype(m.gcDatabasePath)= "C" && The path to the database
			open database (m.gcDatabasePath)
			set database to (m.gcDatabasePath)
		else
			open database mmviscollect
			set database to mmviscollect
		endif
	endif
	endproc

	procedure destroy
	dodefault()
	if this.cOldStatusBar='ON'
		set status bar on
	else
		set status bar off
	endif
	endproc
	
	procedure release
		release this
	endproc

enddefine
And then you would create your class based on PrivateSession class and incorporate your logic into class methods.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform