nErrRetry0 = 0 && Default value nErrRetry1 = 0 && Default valueYou should modify your error procedure. Something like the next:
PROCEDURE ErrorHandler LPARAMETERS nError,cMethod,nLine,cmess,cmess1 Do case Case nError = 1 && File does not exist * You can add here a LOWER(m.cMethod) = cMethodName * if you want to restrict this erro routine to only * selected methods (f.ex command1.click() m.nErrRetry1 = m.nErrRetry1 + 1 IF m.nErrRetry1 < 11 && Counter how many times USE is tried before giving up inkey(0.5,"H") m.nErrRetry0 = 0 RETRY ELSE m.nErrRetry0 = 1 RETURN Endif Case nError = 1104 AND LOWER(m.cMethod) = "hq_this_table_upd" && Error reading file * With the LOWER(m.cMethod) = "hq_this_table_upd" clause you can * restrict this error routine to the methods where it exists and * cannot be recovered easily. * for example inside of SCAN - read data / update data ENDSCAN * would be one candidate. When data is selected (SELECT - SQL) * or table opened with USE from remote computer, the data * is fetched to temporary cursor in your computer. Then when * you modify data, only the data in temporary cursor is modified. * This is then updated to the remote computer with VFP inner routines * (f.ex when closing the cursor) or with TABLEUPDATE() * Therefore you should update remote data record by record * to minimize "connection loosed" problems. You should also add a * lUpdated field to your remote data which is then record by record * updated to .T. if update succeed otherwise application try to update * lUpdated = .F. records again when back in m.cMethod method. * * One possibility to go around this is to use local data -> * Send a flag to remote which collects the data to a temporary data * file and send it to your computer (or you copied it from remote when * data file is generated). Then you modify data in that file and send it * after that back to remote which updaes its own data from that data * file. RETURN Case nError = 1105 && Error writing a file m.nErrRetry0 = 1 RETURN Otherwise * Your normal error routine continues here *Then use next code where the "Error reading file" error happens i.e. where you try to open a table with USE command:
WAIT 'Fetching data from remote 1....' window nowait tmp_select = select() VPN_TEST_FILE = '\\192.168.2.100\MyApplication\data\TestTable.DBF' && Net address of the remote and path to data and file name TMP_TEST_ARR = ADIR(VPN_OK,VPN_TEST_FILE) IF USED("cTableAliasName") USE IN cTableAliasName ENDIF IF TMP_TEST_ARR = 1 && FILE EXISTS CD \\192.168.2.100\MyApplication\data\ IF not used('cTableAliasName') SELE 0 * Normally you have here * USE TestTable ALIAS cTableAliasName && This can generate error reading file * Now you use insted the next: m.nErrRetry0 = 0 m.nErrRetry1 = 0 USE erf_goaround("\\192.168.2.100\MyApplication\data\","TestTable") ALIAS cTableAliasName SHARED ELSE SELE cTableAliasName ENDIF *!* Check here that have not been in error proce OR retry succeed IF m.nErrRetry1 = 0 OR m.nErrRetry0 = 0 * Here your DATA modification / updating etc. or maybe call a function / method * hq_this_table_upd() SELE cTableAliasName USE * messagebox("Data updated (no error or retry succeed") ELSE * messagebox("Data not updated (error and retry not succeed") ENDIF m.nErrRetry0 = 0 m.nErrRetry1 = 0 erf_goaround("\\192.168.2.100\MyApplication\data\") && This closes the remote DBC from your computer ELSE WAIT 'LAN not working to Remote 1...' window timeout 2 ENDIF SELE (tmp_select)erf_goaround function closes the DBC before opening the table becasue it generates "Error reading file" error if connection loosed and DBC open.
LPARAMETER cPATH, cTable LOCAL ; laDBC[1,2], ; lni, ; lnCount, ; lcDBC m.lcDBC = "" adatabase(laDBC) m.lni = ALEN(laDBC,1) IF m.lni > 0 FOR m.lnCount = 1 TO m.lni IF AT(upper(cPATH),upper(laDBC(m.lnCount,2))) > 0 m.lcDBC = laDBC(m.lnCount,2) exit Endif Endfor If !EMPTY(m.lcDBC) SET DATABASE TO (m.lcDBC) CLOSE DATABASE Endif Endif Return cTableYou can get rid of the error but as you can see it needs some work to be done. To get it fool proof you should consider "Flag / TEMP data file"-routine as explained above in paragraph "* One possibility ..."