AndrewMozley
Programmer
I have an application which in its main program opens a database MyData. While I am developing the application the database will perhaps be in my development folder, C:\Dev\Data. At run time it will be in whatever folder the user chooses to use, so perhaps E:\CompanyX\Datafiles. My application handles this fine.
At present, however I tend to open a particular table, say Customers, with an instruction like this in the Init() method :
I feel that I should be using the Data Environment. To that end, during development, I can View the Data Environment, and can open the relevant file, c:\Dev\Data\Customers.dbf. This seems to work OK, and when I run the form I see that fields which I have dragged onto the form do indeed display the relevant values.
However, when I examine the .scx file (by browsing it as a table), I see that the record defining the cursor has its properties field containing :
Alias = “Customers”
Am I doing this right? When the application is installed on the customers site it will presumably try to find a data folder, and this will fail. How can I get round this?
A few further questions.
1. When I am developing the form and go the Data Environment and do Right-Click Add, I thought this might have offered the option of opening a table or a database container. However VFP only appears to offer the option of putting a single table into the environment. I don’t really mind in this case, because I am only concerned with one table, but I wonder whether there is the more general option of including a database within the data environment for a form.
2. When I exit from the form, is the table automatically closed? And if so, where is the code that does that.
3. Although I have a database open within my application, when I open a table, I always refer to it by its .dbf filename. Presumably VFP works out that the table is part of a database and opens that database if necessary. Is there a way of referring to the table by its own name within the database, if that name is different to the name of the .dbf file within the folder?
Sorry for the rather basic questions.
Andrew
At present, however I tend to open a particular table, say Customers, with an instruction like this in the Init() method :
USE Customers INDEX Customers ALIAS Cus IN 0
. . . and at the end I close the table with
SELECT Cus
USE
There are probably better ways, but this is the way that I know !. . . and at the end I close the table with
SELECT Cus
USE
I feel that I should be using the Data Environment. To that end, during development, I can View the Data Environment, and can open the relevant file, c:\Dev\Data\Customers.dbf. This seems to work OK, and when I run the form I see that fields which I have dragged onto the form do indeed display the relevant values.
However, when I examine the .scx file (by browsing it as a table), I see that the record defining the cursor has its properties field containing :
Alias = “Customers”
CursorSource= “..\..\data\customers.dbf”
Am I doing this right? When the application is installed on the customers site it will presumably try to find a data folder, and this will fail. How can I get round this?
A few further questions.
1. When I am developing the form and go the Data Environment and do Right-Click Add, I thought this might have offered the option of opening a table or a database container. However VFP only appears to offer the option of putting a single table into the environment. I don’t really mind in this case, because I am only concerned with one table, but I wonder whether there is the more general option of including a database within the data environment for a form.
2. When I exit from the form, is the table automatically closed? And if so, where is the code that does that.
3. Although I have a database open within my application, when I open a table, I always refer to it by its .dbf filename. Presumably VFP works out that the table is part of a database and opens that database if necessary. Is there a way of referring to the table by its own name within the database, if that name is different to the name of the .dbf file within the folder?
Sorry for the rather basic questions.
Andrew