HighTechTalks DotNet Forums  

Using VB 2008 find out who is using access databae

VB.net microsoft.public.dotnet.languages.vb


Discuss Using VB 2008 find out who is using access databae in the VB.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Ralph Malph
 
Posts: n/a

Default Using VB 2008 find out who is using access databae - 01-21-2010 , 02:01 PM






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,

Ralph Malph

Reply With Quote
  #2  
Old   
Armin Zingler
 
Posts: n/a

Default Re: Using VB 2008 find out who is using access databae - 01-21-2010 , 02:45 PM






Ralph Malph schrieb:
Quote:
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.


Quote:
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

Reply With Quote
  #3  
Old   
Michel Posseth [MCP]
 
Posts: n/a

Default Re: Using VB 2008 find out who is using access databae - 01-22-2010 , 12:18 PM



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 )


HTH

Michel Posseth [MCP]


"Armin Zingler" <az.nospam (AT) freenet (DOT) de> schreef in bericht
news:eaRppqtmKHA.2184 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
Quote:
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




Reply With Quote
  #4  
Old   
Armin Zingler
 
Posts: n/a

Default Re: Using VB 2008 find out who is using access databae - 01-22-2010 , 12:43 PM



Michel Posseth [MCP] schrieb:
Quote:
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

Reply With Quote
  #5  
Old   
Michel Posseth [MCP]
 
Posts: n/a

Default Re: Using VB 2008 find out who is using access databae - 01-23-2010 , 07:05 AM



Quote:
And soemtimes the ldb is left even
if all clients have closed the file.
Well a dirty trick i used in the past ( VB6 when i actually used Access )
was to
try to delete the ldb file to be sure ,check for existence , then try to
delete when a user is in the database the ldb file is locked (you get an
exception when trying to delete the file ) if it is left over from a
unexpected shutdown of an app it is not .

dirty i know but it works :-)

Michel



"Armin Zingler" <az.nospam (AT) freenet (DOT) de> schreef in bericht
news:uilvCM5mKHA.4648 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Quote:
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



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.