![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a VB 2008 that uses an Access 2000 database to hold the programs data etc. I need to add some database maintenance functions in to the program such as database compacting and repairing and data backup and restore. The database file is stored on a file server. In VB 2008, how can I query the database to see if anyone is currently using it before I do any maintenance on it? |
|
If someone does have the database open, how can I force them out prior to doing the maintenance, or at least identify them so that they can be found and asked to log off etc.? Thanks for any help you can provide, |
#3
| |||
| |||
|
|
Ralph Malph schrieb: I have a VB 2008 that uses an Access 2000 database to hold the programs data etc. I need to add some database maintenance functions in to the program such as database compacting and repairing and data backup and restore. The database file is stored on a file server. In VB 2008, how can I query the database to see if anyone is currently using it before I do any maintenance on it? Even if you could, it was useless. If you do something like if not locked then maintenance end if it could be locked _after_ the check - that returns that it is not locked - and before the maintenance. Not very probable, but I think you want it bulletproof. If someone does have the database open, how can I force them out prior to doing the maintenance, or at least identify them so that they can be found and asked to log off etc.? Thanks for any help you can provide, Try to catch the exception. The error message may contain a text like "...is currently locked by user <user>...", but I'm not sure. Any further self-established information about users "logged into the database" is as unsure as the locking information described above. In addition, if a client crashes, it is still recorded as "logged in" even if he is not. I don't know if there's a built-in way to get a snapshot of who's opened the file. I doubt there is one. -- Armin |
#4
| |||
| |||
|
|
Actually you can check pretty easy if someone is using the Access database if there is a ldb file then someone is using the database ( databasename.ldb ) the ldb file is the Access lock file wich is always created unless you have a readonly connection specified on the connection ( wich is normally only done for reading the db from a cd-rom ) |
#5
| |||
| |||
|
|
And soemtimes the ldb is left even if all clients have closed the file. |
|
Michel Posseth [MCP] schrieb: Actually you can check pretty easy if someone is using the Access database if there is a ldb file then someone is using the database ( databasename.ldb ) the ldb file is the Access lock file wich is always created unless you have a readonly connection specified on the connection ( wich is normally only done for reading the db from a cd-rom ) Right, didn't think of that. However, if the check says the ldb doesn't exist, it can be created after the check and before trying to exclusively open the file. That's why I meant with a "useless" check. And soemtimes the ldb is left even if all clients have closed the file. -- Armin |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |