Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shared option in USE command
Message
From
24/09/2014 09:29:17
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 8
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01608037
Message ID:
01608154
Views:
44
>This is exactly what I was asking about.
>
>- My application works just fine with multiple concurrent users using the same bunch of tables for ears without using the SHARE option.
>I am not using EXCLUSIVE anything here. I just use:
>USE tablename IN 0
> - No other option, and Exclusive is OFF.

Exclusive is OFF is why it works.

>
>I never get the "File is in use by another user". Except on this one subroutine. So I am windering why I get it here and not everywhere else.
>And I am not getting it all the time either. Maybe once every 100,000 times when this module is used. So it's pretty rare when I get this error.
>But it is still an error, and it needs to be prevented.
>
>So I would still very much like to really understand what the SHARE option really does?
>Pros and Cons. Or what I gain and what I lose when I use it?

You won't gain anything by it since exclusive is off.

You have a bottleneck there. Multiple people accessing the one file to get a new number. Eventually, one of them will try long enough to time out and you'll get that.

Do you open the table and close it frequently? I'd open it at the start of the app and just select it to generate the key.


>
>Thanks ALL for your comments/answers.
>
>Cyrus
>
>
>>>May sound trivial, but I am Just trying to better understand what the SHARED option does in the USE command.
>>>
>>>It seems to me that the SHARED option is already embedded in USE command, since I can USE a file across a network already, without having to specify the SHARED option. Almost all the tables I open in a Multi-User environment don't have the SHARED option, and they are all open across the network, no problem.
>>>
>>>So my question is, what are the trade offs of using the SHARED option in a USE command ? - What do I lose?, what do I gain?
>>>
>>>Here's why I need to know. Only in one part of the code where I am centrally recoding "The last issued serial #', I have a
>>>USE table IN 0,
>>>command, and in a multi-user environment sometimes they get the error
>>>Error: File is in use by another user.
>>>
>>>So, I am trying to figure out, how can I eliminate this error?
>>>Thanks for your help.
>>
>>That's not trivial. I argue you should NEVER, EVER build a FoxPro add without using SHARED! Exclusive use is the exception, not the rule.
>>
>>USE THEFILE SHARED
>>IF RLOCK()
>> REPLACE serial# with serial# + 1
>> RETURN serial#
>>ENDIF
>>RETURN .F.
Previous
Reply
Map
View

Click here to load this message in the networking platform