It's taken me 4 month to accept that FoxPro store the static location of my database in the form, but now it's really starting to bite me in the ***.
In the statement thisform.SetAll("Database",gcDbPath+gcDbname,"Cursor")
What does "Cursor" do? Thanks!
>VFP forms store the path to the tables used in the dataenvironment. Unfortunately when you deploy an application, your forms may point back to your development directory. These paths should be reset at runtime to ensure they are pointing to the proper tables.
>
>* in your main startup PRG determine the current directory
>* store in global vars or application object
>gcAppPath = sys(2003)
>gcDBPath = alltrim(gcAppPath)+"\data\"
>gcDBName = "mydatabase.dbc"
>
>*modify your form base class to contain the following in the load method (or change each form).
>*also modify your form dataenvironment so make AutoOpenTables=.F.
>
>* point all the tables to the right directory
>thisform.SetAll("Database",gcDbPath+gcDbname,"Cursor")
>* open the tables
>thisform.dataenvironment.opentables()
>
>*NOTE: the above works with tables in a database, the code should be modified if you use free tables.
>
>
>>I've developed an application and when I install it I've found that the directory location is somehow hard coded into the data environment in the form.
>>
>>Example, development directory is k:\launcher\source and the database property of the data environment of the form is k:\launcher\source\accounts.dbf. This can not be changed (in italics). I want my app to look for the database in the same directory that the program resides, not "k:\launcher\source\". So if I install it in c:\program files\launcher\, it should not still be looking on the K drive for data.
>>
>>Is there an easy way to avoid this? What's going on?
>>
>>Thanks!
>>Marvin