>Hi Gang!
>
>We have been banging our heads on a problem that showed up at one of our new clients using our VFP 9 application.
>
>When they run the End of Day, a lot of things are done.. including packing and reindexing the tables.
>
>Randomly, one or more of the tables will come up with a READONLY error in FoxPro. None of the tables or indexes are readonly.
>
>This occurs on the table when we do a DELETE, PACK or REPLACE.
>
>Each day we go in and get them out of the error and continue. We check the table and it IS READ-ONLY !!
>
>Once again, this is totally random. Sometimes it happens, most times it does not. And it happens to different tables at different times when running End of Day.
>
>Also, those tables were on the server. Today, we had it happen to one of our client's work stations!!
>
>Any ideas ?
>
>What can I do to fix this for our client ?
If it's the file itself that is readonly, you can change the attribute of the file like this...
LPARAMETERS tlcFileName
*-----------------------------------*
* Full name of the file is required *
*-----------------------------------*
lcFileName = FULLPATH(tlcFileName )
*--------------------------------------*
* Define constants for file attributes *
*--------------------------------------*
#DEFINE FA_NORMAL 0 && Normal file. No attributes are set.
#DEFINE FA_READONLY 1 && Read-only file.
#DEFINE FA_HIDDEN 2 && Hidden file.
#DEFINE FA_SYSTEM 4 && System file.
#DEFINE FA_ARCHIVE 32 && File has changed since last backup.
#DEFINE FA_VOLUME 8 && Disk drive volume label. Attribute is read-only.
#DEFINE FA_DIRECTORY 16 && Folder or directory. Attribute is read-only.
#DEFINE FA_ALIAS 1024 && Link or shortcut. Attribute is read-only.
#DEFINE FA_COMPRESSED 2048 && Compressed file. Attribute is read-only.
oFSO = CREATEOBJECT("Scripting.FileSystemObject")
oFile = oFSO.GetFile(lcFilename)
*-----------------------------*
* Turn off the read-only flag *
*-----------------------------*
oFile.Attributes = BITAND(oFile.Attributes, BITNOT(FA_READONLY))
*-------------------------------------------------------------------*
* Display status of the read-only flag *
* ? IIF( BITAND( oFile.Attributes, FA_READONLY) > 0, "RO", "RW") *
* *
* Flip read-only flag *
* oFile.Attributes = BITXOR(oFile.Attributes, FA_READONLY) *
* *
* Turn on the read-only flag *
* oFile.Attributes = BITOR(oFile.Attributes, FA_READONLY) *
*-------------------------------------------------------------------*
....if its the table that's read-only for some reason then maybe since you're doing that PACK you still have exclusive use of it and need to close and re-open it??
ICQ 10556 (ya), 254117