Pack Command

Topics: User Forum
Sep 22, 2015 at 10:59 PM
I'm making a new front-end for an existing database which I don't have access to the source code. I really appreciate the overall ease of use of ActiveVFP, except when there is a syntax error.

In some cases the original application has SET DELETE OFF which causes deleted items to appear when they should not and the only way to get rid of them is to run PACK command often (this is one of many deficiencies of the original system). In the original application there is a menu item to run the pack command, but it insists I kick all users out of the system which is the part that isn't easy. It will be some time before the new front-end is complete, but in the meantime I would like to be able to call PACK which should succeed as long as no other user has this particular table open, which is fairly likely.

Unfortunately calling PACK from ActiveVFP causes IIS (Express 7.5 or 8) to hang up. IIS hangs up even if I wrap the PACK command in TRY...CATCH, even though it finishes rendering the page. I have to reset IIS after that. Even after the new front end is complete, PACK is going to be needed for maintenance anyway.


Error message always seems to be the same when IIS crashes:

Creating an instance of the COM component with CLSID {BEF60CED-FB7C-4835-A927-4EC90F5162CB} from the IClassFactory failed due to the following error: 80004005 Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)).

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Creating an instance of the COM component with CLSID {BEF60CED-FB7C-4835-A927-4EC90F5162CB} from the IClassFactory failed due to the following error: 80004005 Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[COMException (0x80004005): Creating an instance of the COM component with CLSID {BEF60CED-FB7C-4835-A927-4EC90F5162CB} from the IClassFactory failed due to the following error: 80004005 Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)).]
AVFPHandler.ProcessRequest(HttpContext context) +51
AVFPHandler.OnInit(EventArgs e) +36
System.Web.UI.Control.InitRecursive(Control namingContainer) +134
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +489
Sep 23, 2015 at 3:03 PM
In one of my AVFP project, i use the PACK command without problem. This is an example of code that i use:
<%
use oProp.DataPath + "client" in 0 alias client exclusive
pack in client
use in client
%>
if you can, write some line of your source code.
Sep 23, 2015 at 5:59 PM
Thank you mr_ocean,

It turns out it wasn't the PACK command that was causing the hang up. It was CLOSE ALL. When I took that line out it worked.

I had trouble getting exclusive access and tried CLOSE TABLES ALL, which does not crash the server, but it didn't help me get exclusive access, so I tried removing TABLES. It's strange because I thought I had exclusive access before trying to get the PACK command to work. But I think it's the TRY...CATCH which prevents the server crash from being apparent until the next request.

Is there a better way to determine if USE EXCLUSIVE fails or not?
Coordinator
Sep 24, 2015 at 2:23 PM
You can't use CLOSE ALL in your AVFP code because it will close and unload function libraries that are required for AVFP to work. What you should do is use AUSED() function to get a list of all opened data sources and then close them one by one after you finished handling your request. If you are using AVFP 6.03 this can be put in the main.prg file. If you are using my experimental modified version, you can use the onCloseDataSession event at delegate.prg.

Victor Espina
Sep 24, 2015 at 10:22 PM
Thank you vespina

The only reason I put the CLOSE command at all was because if IIS didn't hang up, it seemed to leave the table in a used state which I couldn't open exclusively.

The CLOSE command won't release tables which are open by people using the original application and there is no functionality in the original application to disconnect/kick out anyone. I can set a "lockout", but it doesn't really do anything. Users can ignore the lockout and finish whatever they are doing, but if they went on lunch break or whatever, sometimes they go home with a table left open on their screen, I'm left waiting.
Coordinator
Sep 28, 2015 at 12:26 PM
Yes, I totally understand the situation. That's why we are not supposed to use PACK for anything but regular database maintenance tasks. In your case, it seems all the problems are caused by the original application (set DELETED to off, not implementing a way to kick users from the app); if you can't fix those problems, I don't think you can do anything from the outside.


Victor