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!

VFP6 - Error 111- when file is NOT Readonly

Status
Not open for further replies.

Irwin

IS-IT--Management
Jan 21, 2002
25
US
Here is the problem I am having. I was running a table locking test when assigning invoice numbers. the test was being run from 3 different workstations at the same time and I kept getting "Error 111" when accessing the 'control' table. I could understand if I got the 'File in use by another user [108]. Below is the code used to run this test.

******************************************
SET TALK OFF
SET ECHO OFF
CREATE TABLE (TEMP3) (INVNO C(6), INVDATE D(10),;
AMOUNT N(10,2))

use TEMP3 shared

FOR X = 1 TO 10000
PRIVATE MINVNO
STORE "" TO MINVNO
SELECT 0
mINVNO=invnumb(X)
SELECT TEMP3
APPEND BLANK
REPLACE INVNO WITH MINVNO, INVDATE WITH CDATE, ;
AMOUNT WITH X
WAIT WINDOW("INV "+mINVNO) NOWAIT
ENDFOR
*************************************************
*************************************************
FUNCTION invnumb
LPARAMETER p1 && pass amount invoiced
LOCAL p2 && P1=amount P2= new invoice number

use "control" exclu
STORE STR(INVNO,6) TO p2
REPLACE INVNO WITH IIF(INVNO=999999,1,INVNO+1)
use
RETURN(p2)
endfunc
***********************************************************

Any Help is appreciated

Irwin
 
Hi Irwin,

You have disregarded the work area assignments.

Simply using the code such as ..

use TEMP3 shared
use "control" exclu
.. will use the same current work area.. and so in order to open the new table specified.. the earlier table in that area will be closed.

The correct usage will be..

CREATE TABLE (TEMP3) (INVNO C(6), INVDATE D(10),;
AMOUNT N(10,2))

Assumed Temp3 is a variable since used in ()..
Also after creation, the work area stands selected and the table is left open in exclusive way..
SO.. to close it..
USE

To open it again..
USE (Temp3) AGAIN IN 0 ALIAS temp3 SHARED
SELECT TEMP3


again in your function..
*************************************************
FUNCTION invnumb
LPARAMETER p1 && pass amount invoiced
LOCAL p2 && P1=amount P2= new invoice number

use "control" IN 0 ALIAS control EXCL
GO TOP IN control
STORE STR(control.INVNO,6) TO p2
REPLACE control.INVNO WITH ;
IIF(control.INVNO=999999,1,INVNO+1)
use IN control
RETURN(p2)
endfunc
***********************************************************
** Note I have referenced always with the alias name.. control.. and I have not selected the control as the default alias. This is to avoid remaining in the ear;ier selected work area. Another way to do this is..
*************************************************
FUNCTION invnumb
LPARAMETER p1 && pass amount invoiced
LOCAL p2 && P1=amount P2= new invoice number
LOCAL lcALias
lcAlias = ALIAS()

use "control" IN 0 ALIAS control EXCL
SELECT control
GO TOP
STORE STR(INVNO,6) TO p2
REPLACE INVNO WITH IIF(INVNO=999999,1,INVNO+1)
use IN control
SELECT (lcALias)
RETURN(p2)
endfunc
***********************************************************

Hope this solves your error :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top