Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Including Tables into the Project
Message
De
10/07/1997 17:19:30
Renato De Giovanni
Via Fractal Information Systems
São Paulo, Brésil
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00036447
Message ID:
00039351
Vues:
43
>>Now suppose you are within a Private DataSession and you know "Customer" dbf is not opened there (In other words, there are no alias names related to that table). Then, shouldn't you faithfully and happily issue: USE customer ?
>>
>>Well it returns me a "File is in USE" when it's not really in use at that specific DataSession (just remembering that it only happens when the table is not available in the Data directory; it's included into the Project).
>Renato,
>
>Yes it will give you the file in use error, data sessions are really smoke and mirriors, if the dbf ifle is open anywhere then you must use the AGAIN even if it is open in another data session. That is eaxactly what the Data Environment does automatically for you if you put the table in the form's DE.

Hi Jim!

I've finally found some time to retake this issue and to try your suggestion. Unfortunately the problem persists (maybe I'm doing something wrong).
In any case, if you wish, you can easily reproduce the situation using the following steps:

1- Create a new table with this command line: CREATE TABLE OurTable (OurField C(30))
2- Create a new Project.
3- Insert OurTable into the Project (excluded).
4- Insert the Main.prg into the Project copying the following code:
****** Main.prg *******
PUBLIC oForm
oForm = CREATEOBJECT('Form1')
oForm.Show

DEFINE CLASS 'Form1' AS FORM
Caption = 'Main Form'
Height = 50
Width = 150

ADD OBJECT Button1 AS CommandButton;
WITH AutoSize = .T., Caption = 'Create Instance'

PROCEDURE Button1.Click

LOCAL lc_name
lc_name = 'oForm' + ALLTRIM(STR(_SCREEN.FormCount))
PUBLIC (lc_name)
&lc_name = CREATEOBJECT('Form2', ALLTRIM(STR(_SCREEN.FormCount)))
ENDPROC
ENDDEFINE

DEFINE CLASS 'Form2' AS FORM
AutoCenter = .T.
Height = 100
Width = 200
DataSession = 2

PROCEDURE INIT

PARAMETERS pc_num
SET TALK OFF
THISFORM.Caption = 'Instance number ' + pc_num
THISFORM.Show
ENDPROC

PROCEDURE LOAD

USE OurTable IN 0
ENDPROC
ENDDEFINE
**************************
5- Build and EXE and run it: You'll see that it's possible to create many instances of Form2 - all of them using OurTable in their Private DataSessions without the AGAIN ALIAS clause.

6- Now, return to the Project, mark OurTable as included, build another EXE, move OurTable to another directory, and run the EXE. When you try to create the second instance you'll get the error *File is in use*. That's the problem I've reported before.

7- Finally, move OurTable back to the original directory, open the Main.prg, change the line USE OurTable IN 0 with USE OurTable AGAIN ALIAS OurTable IN 0, build another EXE, move OurTable to another directory, and run the EXE. You'll see that, unfortunately, we've got the same problem.

Well, thanks again anyway,

Renato
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform