Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dataenvironment stores full path?

Status
Not open for further replies.

thatguy

Programmer
Aug 1, 2001
283
US
hello all --

i just noticed that in the dataenvironment of my form, the full path is used for the location of the database that the table belongs to - meaning drive letter and directory. is there any way to get a relative path in there?

to save time/effort moving the exe over to the production machine, i'm developing the database on the prod machine and just building the exe to the live directory, but of course, because of the above problem, the exe is looking at the test data and not the live data. however, if i change the name of the test directory, the exe uses the live data! any suggestions? thanks!

-- michael~
 
Instead of using data environment. You can can manualy call up the database and table before starting of the form.
Example call the database in the Load or Init Method.
 
Michael,
Actually, while the full path is displayed, I believe that the DE as well as the DBC store these as relative to the Database (DBC) location as long as the table exists on the same drive.

Rick
 
thanks for the reply and sorry for the delay .. been away awhile..

rick - i'm seeing something different than what you describe. i mentioned in the first post that the exe uses the test data until i change that directory name. for example: i develop in a dir called c:\test with data stored in c:\test\data. i build to and run the exe from c:\prod with the live data in c:\prod\data. however, the exe uses the data in c:\test\data unless i change that dir name to something else (c:\t\data), only Then will the data in c:\prod\data be used.

so from this, it seems like the dbc uses relative paths Only when the original full path cannot be found. sound right? any ideas to get around this (besides renaming the test directory every time i run the exe, and besides manually opening each table in the form.load() [because that just seems messy])?

thanks!
-- michael~
 
Michael,
Do you set the DEFAULT and/or PATH in your CONFIG.FPW file? Do you compile that CONFIG.FPW into the .EXE? Do you set the DEFAULT and/or PATH in you program's start up code before opening the database or tables?

Try the following:
Code:
use your.dbc noupdate
browse
Then look at the Property field for the Database/Database record and all the Table records. These should represent the "pathing" the DBC uses (ignore the non-alpha characters). In a simple case where the DBC and all the tables are in the same directory, the first record should have nothing in it, and the others will just have the table names.
If your's is different, then did you create the DBC and then move around the tables? Were the tables ever on a drive different from the DBC?

Rick
 
The best way I've seen to handle it is to place some code in the Form DEBeforeOpenTables that changes the path programatically. Such as:

1) Set Autoopentables to .f. in DE

2) Then call Form method from LOAD. The parameter lcDataLocation has to be initialized somewhere with path you want to use.:

lparameters lcDataLocation
local laObjects[1], ;
lnObjects, ;
lcDirectory, ;
lcCommon, ;
lnI, ;
loObject, ;
lcDatabase, ;
lcTable
lnObjects = amembers(laObjects, toDE, 2)
lcDirectory = oApp.cDataDir
for lnI = 1 to lnObjects
loObject = evaluate('toDE.' + laObjects[lnI])
if upper(loObject.BaseClass) = 'CURSOR'
lcDatabase = loObject.Database
if empty(lcDatabase)
lcTable = loObject.CursorSource
loObject.CursorSource = lcDirectory + ;
substr(lcTable, rat('\', lcTable) + 1)
else
loObject.Database = lcDirectory + ;
substr(lcDatabase, rat('\', lcDatabase) + 1)
endif empty(lcDatabase)
endif upper(loObject.BaseClass) = 'CURSOR'
next lnI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top