Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unusual 1705 Error
Message
 
 
À
01/05/2001 15:25:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00501780
Message ID:
00502319
Vues:
12
Why not just close all before opening this table? It could be opened under another alias, etc. Also I never use direct USE in myh applications. I use my little UDF for that: (I modified this code today at work, so it's not my current version, but anyway):
********************************************************************
*  Description.......: OpenTble && Opens the passed table
*  Calling Samples...: OpenTble('TranMstr','WorkFile')
*  Parameter List....: tcTable, tcAlias, tcMode, tcTagOrder, tnBufferMode
*  Created by........:
*  Modified by.......: Nadya Nosonovsky 01/10/2001 11:46:19 AM
********************************************************************
function OpenTble && Opens, but didn't select a table
lparameters tcTable, tcAlias, tcMode, tcTagOrder, tnBufferMode
*=messagebox( "tcTable "+tcTable+ chr(13)+"tcTagOrder "+iif(!empty(tcTagOrder),tcTagOrder,""))
* tcTable - required: name of table to open (with or without full path)
* tcAlias - optional: alias name, if different from tcTable
* tcMode - optional:  mode in which table should be opened, like Shared noupdate
* tcTagOrder - optional: Tag name
* tnBufferMode - optional: Set buffer mode
local lcTableName, lnPos, llDBCPrefix, lcDBCName
* Check parameters first
if empty(tcTable) or vartype(tcTable)<>'C'
* First parameter is required
     return .f.
else
     lnPos=rat('!',tcTable)
     if lnPos>0 && DataBase Name was specified && example: Support!PostOff
          lcTableName=juststem(substr(tcTable,lnPos+1)) && PostOff
          lcDBCName=upper(left(tcTable,lnPos-1)) && DBC Name
          llDBCPrefix=.t.
     else
          lcTableName=tcTable
     endif
endif
if empty(tcAlias) or vartype(tcAlias)<>'C'
     tcAlias=juststem(lcTableName)
endif

if empty(tcMode) or vartype(tcMode)<>'C'
     tcMode='shared'
else
     tcMode=lower(tcMode)
endif
local lcCheckFile
if empty(justext(lcTableName))
   lcCheckFile=forceext(lcTableName,"dbf")
else
   lcCheckFile=lcTableName    
endif  
if !file(lcCheckFile)  && File doesn't exist
     =messagebox(tcTable +' does not exist!. Can not proceed...',48,'Error')
     return .f.
endif
local lnOldSelect
lnOldSelect=select()
if !used(tcAlias) or ; && Alias is not already in use or 
        (llDBCPrefix and not juststem(cursorgetprop("DATABASE",tcAlias))==lcDBCName) && it's not the same database
     local lcOldError, lnErr, lcOldSetExclusive
     use in select(tcAlias) && Close table
     lnErr=0
     lcOldError=on('error') && Save current Error Handler
     lcOldSetExclusive=set('exclusive') && Save current exclusive status
     set exclusive off && This should be always set this way
     on error lnErr=error()
     use (tcTable) again &tcMode in 0 alias (tcAlias)
     on error &lcOldError && Restore previous Error Handler
     if lcOldSetExclusive='ON'
          set exclusive on && Restore it back to original settings
     endif
     if lnErr<>0 && Error occurs
          if lnErr=1705  && File Access is denied
               =messagebox(tcTable +' is opened exclusively by another user. Can not proceed...',48,'Error '+transform(lnErr))
               return .f. && Table could not be opened (already used exclusively)
          else && Another error
               =messagebox(tcTable+' could not be opened!',48,'Error '+transform(lnErr))
               return .f.
          endif
     endif
endif

select (tcAlias) && If it's here, everything is all right
if not empty(tcTagOrder) and vartype(tcTagOrder)='C' and tagno(tcTagOrder)>0
     set order to tag (tcTagOrder) in (tcAlias)
endif 
if vartype(tnBufferMode)='N' and between(tnBufferMode,1,5)
    set multilocks on
     =cursorsetprop('Buffering',tnBufferMode) && Note, we can not set buffering mode less than 3 on a view - no check for this
endif
select (lnOldSelect) && Return back to the original area
return .t.
>>>We have been receiving this 1705 error when trying to open a table exclusively and we're trying to track down the problem. This error is not consistent. It occurs once every two weeks.
>>>
>>>We are running an exe that does some heavy data processing. Below is an example of the code.
>>>
>>>... Heavy data processing ...
>>>
>>>
>>>Flush
>>>
>>>Sys(1104)
>>>
>>>>>Close Databases All
>>>
>>>If Used(  )
>>>    Use In 
>>>EndIf
>>>
>>>Use  In 0 Exclusive
>>>
>>>
>>>
>>>This last generates a 1705 error.
>>>
>>>File access is denied (Error 1705)
>>>You have attempted to write to a file that is write protected.
>>>
>>>We are guessing that after the heavy processing the files have not closed properly, which is why we are getting that error. But why a 1705? Why not a "File is in use." error?
>>
>>Have you tried FLUSH ahead of your USE ... EXCLUSIVE?
>
>Yes. See there is a FLUSH in the code.
>
>:) Before you check the previous messages, I just added that Flush. I should have included that in the first message. Have you actually received a 1705 error when trying to open a table exclusively?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform