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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Exclusive On

Status
Not open for further replies.

Zady

Programmer
Oct 17, 2001
9
US
) look at this code
___________________
------------------------
Set exclusive on
select myTable
delete tag myTag
index on myField tag myTag for myFileteringExpression
set exclusive off

--------------------
_________________
Why do I get File must be open exclusively?
What is the compromise to share myTable and open it exclusively when needed?
I thought set exclusive on and off would do
 
If a table it is open with SET EXCLUSIV OFF and you change later in SET EXCLUSIV ON your table will remain with EXCLUSIV OFF access.
One solution can be this (in your program):

use mytable share
or
use mytable exclusiv

If you wan't to index /reindex your table you must have exclusive access , so you must have a procedure in your program for exclusive access operations (pack,index,zap,etc.)


 
Hi Zady,

********************************
Set exclusive on
select myTable
USE
USE myTable
delete tag myTag
index on myField tag myTag for myFileteringExpression
USE
set exclusive off
*********************************
The above code shall do the trick...
The reason why didnot work is, that the file was already open as shared. Hope this helps you :)
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 

Hi Ramani!
Hi Catalin!
Thanks for you reply!

One important thing that I did not mention is that, I use myTable as the recordSource of a grid on a form in a multi-user environment.
I have tried to close myTable but this left my grid without its RecordSource (=myTable). As you may know and I found out, this become a bigger problem for my user interface( My grid just became a white square box). After re-indexing myTable when I set back RecordSouce to myTable. All the properties of my grid are set back to their default values. Now I think I need to create a routine that setup all the property including the event handler of my grid and call that routine after I re-index myTable. This is not an easy task knowing I have 27-column grid where each column must be handled differently. The other problem is (correct me if I am, you know I am just a rookies in Visual FoxPro) in a multi-user environment chances are another user may be using myTable, can I at will close it without affecting any other users? Isn’t that the reason why VFP does not change the accessibility of a table once open with SET EXCLUSIVE OFF even if you change back to SET EXCLUSIVE ON.( courtesy of CatalinC)?

The reason why I ran into this dilemma is that one of my index filtering criteria is based on a PUBLIC variable myPublicVariable that dynamically changes value, unless I re-index myTable, the grid of my form shows no record. Is there any other way to get around this, in a multi-user environment?

Thanks!
 
HI
I would suggest you to think with following code..


********************************
ThisForm.myGrid.Visible = .F.
ThisForm.RecordSource = ""
** Then continue with the above codes...
Set exclusive on
select myTable
USE
USE myTable
delete tag myTag
index on myField tag myTag for myFileteringExpression
USE
set exclusive off
** Now reinstate the whole again..
USE myTable ORDER myOrder ALIAS myALias
ThisForm.RecordSource = myAlias
ThisForm.myGrid.Refresh()
ThisForm.myGrid.Visible = .t.
*********************************

Hope this helps you :) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Hi Ramani

Thanks everything works fine with myGrid. However I still want to know if it's ok to close a shared file in a multi-user environment?. If yes what happen to users that have the file open when another closes it?

New Question
-------------

in myGrid if I wanted to set all the clik event of the TEXT1 field to fire the event myEvent.prg. I thought I could use the property setting method SetAll("click", "DO myEvent.prg", "COLUMN.HEADER.TEXT1") unfortunately it does

Thanks again!

Zady
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top