Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cursor-objects in dataenvironment don't find database
Message
De
06/09/2000 10:28:05
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00412837
Message ID:
00412926
Vues:
15
>I've got several forms which get their data from tables in the dataenvironment. My Problem is now: when I copy my compiled runtime-files (with Database-Directory) to another directory the cursor-objects in the dataenvironment do not find the database.

You can make this code reusable if you have a global variable or Application property that holds your data directory.

First turn AutoOpenTables in your DE to .F.

Add this code like this to the Load() event of your form (you could put this in a class so you don't need to remember to put it in every form):
LOCAL lnCnt, loObj, lcDBC, lcNewDataPath

lcNewDataPath = ***A property or somethign with your Datapath in it

LOCAL ARRAY laList[1]

*** Get Object Members of DE
=AMEMBERS(laList, THISFORM.DATAENVIRONMENT, 2)
IF EMPTY(laList[1])
	*** Nothing in DE
	RETURN
ENDIF

IF ALEN( laList,1 ) > 0
	FOR i = 1 TO ALEN(laList,1 )
		loObj =  EVAL("ThisForm.DataEnvironment."+laList[i])
		IF LOWER(loObj.BASECLASS ) = 'cursor' AND "\" $ loObj.DATABASE
			IF !EMPTY(loObj.DATABASE)
				*** Contained Table
				lcDBC = SUBSTR(loObj.DATABASE, RAT('\', loObj.DATABASE))
				loObj.DATABASE = tcNewDataPath + lcDBC
				IF !DBUSED(loObj.Database)
					OPEN DATABASE (loObj.Database)
				ENDIF
				SET DATABASE TO (loObj.Database)
			ELSE
				*** Free Table
				lcDBC = SUBSTR( loObj.CursorSouce, RAT('\',loObj.CursorSouce))
				loObj.CursorSouce = tcNewDataPath + lcDBC
			ENDIF
		ENDIF
	NEXT
ENDIF

* Now open the tables
Thisform.DataEnvironment.OpenTables()
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform