Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Seperate DBC for each project number?
Message
De
08/08/1999 17:09:38
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00251276
Message ID:
00251294
Vues:
10
>In putting together an app, I ask the user for a project number upon startup. If the project does not exist, I'd like to replicate the DBC and it's tables in a sub-directory and use that as the data for my main application.
>
>I'm wanting to do this for easy backup, organization and archiving - and to make it easier for users to manage their files.
>
>That being said, I'm having trouble figuring out how to create the data environment of my primary application. How do I tell my form to look in a certain directory for it's DBC, instead of the one I used for design? Do I need to empty the data environment and instead open the tables and create the relationships in the calling program? I know this is the way I always used to do it - perhaps I'm just getting lazy!
>
>TIA

You just need to change the database property for the objects in the dataenvironment of each form. This has to be done before the tables are opened, so do it a ,method called from form.load or Form.DataEnvironment.BeforeOpenTables. Here is the code from my ChangeDataPath method in my base form class. It is called with the path as a parameter, usually from form.load. The form gets its datapath from the application object.
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