Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I change dbc path in form
Message
From
10/10/2006 15:21:09
 
 
To
10/10/2006 10:40:12
Arjun Bagojikop
Dynamic Super Software
Sangli, India
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01160849
Message ID:
01161013
Views:
20
I have the following procedures:
************************************************************************************************
*
*  Routine for setting the database directory location for the form
*
FUNCTION SetDBCPath
LPARAMETERS poFormDE,pcDBCPath,pcDBCName
LOCAL lcDBCName, lcFilePath, lnNumCursors, lnNdx
lcDBCName  = FORCEEXT(pcDBCName,"DBC")
lcFilePath = ADDBS(pcDBCPath) + lcDBCName
lnNumCursors = AMEMBERS(lcProperties,poFormDE,2)
FOR lnNdx=1 TO lnNumCursors
	IF UPPER(LEFT(lcProperties[lnNdx],6)) = "CURSOR"
		IF ATC(lcDBCName,poFormDE.&lcProperties[lnNdx]..database) > 0
			poFormDE.&lcProperties[lnNdx]..database = lcFilePath
		ENDIF
	ENDIF
ENDFOR
ENDFUNC
This is called in the Dataenvironment.BeforeTablesOpen() event:
SetDBCPath(this,gcDBCPath,"Data")
Where "Data" is the name of the database, and gcDBCPath is the location of the database at runtime. The variable gcDBCPath is global (or can be a custom property added to _SCREEN) and determined at the start of the program. This will change the location of the tables within the database for the dataenvironment.

For free tables, use the following:
************************************************************************************************
*
*  Routine for setting the free table directory location for the form
*
FUNCTION SetDBFPath
LPARAMETERS poFormDE,pcDBFPath
LOCAL lnNumCursors, lnNdx, lcDBFName
LOCAL ARRAY lcProperties[1]
lnNumCursors = AMEMBERS(lcProperties,poFormDE,2)
FOR lnNdx=1 TO lnNumCursors
	IF UPPER(LEFT(lcProperties[lnNdx],6)) = "CURSOR"
		IF EMPTY(poFormDE.&lcProperties[lnNdx]..database)
			lcDBFName = JUSTFNAME(poFormDE.&lcProperties[lnNdx]..CursorSource)
			poFormDE.&lcProperties[lnNdx]..CursorSource = pcDBFPath + lcDBFName
		ENDIF
	ENDIF
ENDFOR
RETURN
ENDFUNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform