Hi,
I have this problem, after some database operations (mixed DBF CDX and SQL) and database is Visual Foxpro , stay one DBF with CDX open.
But when I put Close all, and test if any database is open not see any DBF opened.
This look, to database is opened in some other thread, which I not see from main program...
When I want delete database from disc, cannot, only when I close program.
How can I close database in all threads ?
Open database in thread ?
Re: Open database in thread ?
Close them in the threads. Put a DbCloseAll() just right before the "RETURN".How can I close database in all threads ?
Another way would be to transfer the tables from the workspace of the thread to the "zerospace" and collect them from there in the main thread. DbRelease() and DbRequest() can do this. But why? Just close your tables before returning from the threads.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Open database in thread ?
Hi Tom,
In individual functions, I have closing databases either Close alias or Close all
Even in the function, after closing which the database on the disk remains blocked, I have Close all, DBCloseall(), but still after closing it, but if the main program remains on, the DBF and CDX files on the disk remain open,
If I test whether they are open via ALIAS or USED(), the program reports that they are not open, so I think that in the complex structure of the program the database somehow remained open twice, e.g. via SELECT 30, but I no longer have access to this Thread, or it is open somewhere in the background, but I can't figure out how to close it.
It IS possible that it was blocked by the SQL system (I use SQLExpress++ from Boris Borzic), because I open this database both via DBFCDX and via the ODBC Driver.
The problem is that I can't find out what blocks the DBF, CDX files on the disk. If I close the program, they are unblocked.
In individual functions, I have closing databases either Close alias or Close all
Even in the function, after closing which the database on the disk remains blocked, I have Close all, DBCloseall(), but still after closing it, but if the main program remains on, the DBF and CDX files on the disk remain open,
If I test whether they are open via ALIAS or USED(), the program reports that they are not open, so I think that in the complex structure of the program the database somehow remained open twice, e.g. via SELECT 30, but I no longer have access to this Thread, or it is open somewhere in the background, but I can't figure out how to close it.
It IS possible that it was blocked by the SQL system (I use SQLExpress++ from Boris Borzic), because I open this database both via DBFCDX and via the ODBC Driver.
The problem is that I can't find out what blocks the DBF, CDX files on the disk. If I close the program, they are unblocked.
Re: Open database in thread ?
Hi, Victorio.
Sometimes, closing tables fails for some reasons. The main reason is open relations, but sometimes, closing tables even fails because of record locks, some kind of scopes or other reasons. But: The runtime error system raises a "Table cannot be closed" error in that situation. Maybe you replaced the standard error system, so you don't get this error. Anyway, travelling through the WorkSpaceList(), releasing all relations, releasing all locks and closing all tables step by step (check if closed with "Used()" or other functions) should remove this problem. I remember Roger wrote a function for this long time ago. I have my own, so I don't remember the function name.
Sometimes, closing tables fails for some reasons. The main reason is open relations, but sometimes, closing tables even fails because of record locks, some kind of scopes or other reasons. But: The runtime error system raises a "Table cannot be closed" error in that situation. Maybe you replaced the standard error system, so you don't get this error. Anyway, travelling through the WorkSpaceList(), releasing all relations, releasing all locks and closing all tables step by step (check if closed with "Used()" or other functions) should remove this problem. I remember Roger wrote a function for this long time ago. I have my own, so I don't remember the function name.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
-
- Posts: 481
- Joined: Wed Jan 27, 2010 10:25 pm
- Location: Berlin Germany
Re: Open database in thread ?
I think, Roger integrated the releasing all relations, releasing all locks in DC_DbCloseArea() .and. DC_DbCloseAll().
_______________________
Best Regards
Wolfgang
Best Regards
Wolfgang
Re: Open database in thread ?
Thanks for thanks for trying to help,
now I found problem !
because database is not open by standard DBF (via DBFCDX), everything pointed to a SQL problem.
When I closing connections with oConnection:destroy(), database was still blocked
When put oConnection:DestroyContext(), dbf was released, and cannot delete it.
That solved
Have a nice day,
Viktor
PS: when you use SQLExpress++, description for DestroyContext :
Kills all connections that were created in current thread. By default a codeblock that calls this method is automatically assigned to the current thread's :atEnd ivar when the ivar is empty. This ensures that all connections (and statements created on that connection) are properly destroyed at thread termination.
now I found problem !
because database is not open by standard DBF (via DBFCDX), everything pointed to a SQL problem.
When I closing connections with oConnection:destroy(), database was still blocked
When put oConnection:DestroyContext(), dbf was released, and cannot delete it.
That solved
Have a nice day,
Viktor
PS: when you use SQLExpress++, description for DestroyContext :
Kills all connections that were created in current thread. By default a codeblock that calls this method is automatically assigned to the current thread's :atEnd ivar when the ivar is empty. This ensures that all connections (and statements created on that connection) are properly destroyed at thread termination.
Re: Open database in thread ?
edit:
When put oConnection:DestroyContext(), dbf was released, and can delete it.
That solved
When put oConnection:DestroyContext(), dbf was released, and can delete it.
That solved