Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Articles
Search: 

Private Datasessions
Javier Borrajo, January 1, 2001
I have just transformed my whole application to private dataSessions. Private data sessions are not what you really think they should be, i.e. really private data sessions, and this is why I had to make a lot of workarounds for the app to work. So I decided to resume some of my experiences so that a...
I have just transformed my whole application to private dataSessions. Private data sessions are not what you really think they should be, i.e. really private data sessions, and this is why I had to make a lot of workarounds for the app to work. So I decided to resume some of my experiences so that any one interested in taking the same step I took won't fall in the same mistakes.

In a Private DataSession there are a lot of SET commands that are private to the form. This is very well known, but is not so well known that the complete list of SET commands that are private to the form is in the VFP HELP file under the 'SET DATASESSION' topic.

Tables opened in the DataEnvironment (DE) of a form with a private data session are not really private and independent. What VFP does is something like a USE AGAIN ... This way, if you have a table opened as read only in one form and then want to open another form wich uses the same table in readable form, the second form fails to open OK the table and it is opened as read only.

Eventhough it makes something like a USE AGAIN, it does not know anything about tables opened manually, i.e. tables that are not included in DE. This means that as long as you include tables in DE in all forms, is going to work OK. But if for some reason you open a table manually (with USE) in any method of the form, others forms that may attemp to open this table in the DE will generate an error message and will fail to initiate. For example, if you open a generic table in the main program of an application, and want to use the same table in a form with a private datasession and you include the table in the DE, it will prompt with the error message: 'Table is already in use'. If you check in the BeforeOpenTables for the existence of such a table, it will tell you that is not opened. Weird, i know. This means that if you want to avoid problems you will have to include all tables in the DE.

Because of the behavior of the last point, be very careful with the SELECT-SQL command, as it automatically opens the tables involved in the query. This way, you have to close the tables just after the SELECT command. Other approach is to include every table that is going to be used in SELECT-SQL commands of a Form into the DE of the form.

You cannot open a table in exclusive form if you want to include this table in other forms. This means that you cannot perform certain commands (such as PACK, INEX, ...) that need the table to be opened in exclusive form. If you plan to use one of this commands you will need to create a way to check that none Form is opened so you will avoid conflicts; for the same reason, the form with such a command will have to be modal so as to avoid another form to be opened and avoid potential conflicts.

I had other problems, but I don't remember them now. All I hope is that this few points will save time to any one.