Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing the Location of Tables
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00271934
Message ID:
00271963
Vues:
17
>I have a project I’m working on at the office. The tables for the project are on a different computer and I’m accessing them using a Set Path To \\NT1\Public\Data. On the weekends I want to bring the project home, so I restore the tables in a local folder at home like C:\VFP\Data. I change my default path and search path in Tools/Options. I remove the tables from my data environment and from the project then add them back in. Then I change my Set Path To C:\VFP\Data. I can’t get VFP to see my new path or tables. Not only won’t it see the path, it also changes my search path back to \\NT1\Public\Data.
>Where is this coming from and how can I do this?
>
>Thanks in advance

This path information is stored in properties of cursor objects in the dataenvironment. The common way to handle this is with a routine that runs before thetables are opened, that loops through the cursors in the DE, and changes the database property depending on some current setting: a registry entry, a public variable, form property, etc. My framework has a ChangeDataPath routine that is called from the form.load that does this.
LPARA tcNewDataPath

LOCAL lnCnt, loObj, lcDBC, lcNewDataPath

IF TYPE("tcNewDataPath") <> "C"
	RETURN .F.
ELSE
	lcNewDataPath = tcNewDataPath
ENDIF

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
Erik Moore
Clientelligence
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform