473,544 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you determine if anyone is logged onto a BE database?

I have a system on a network and want to determine if anyone is currently
connected to the back-end files.

An interesting twist is that I have noticed that some users can be connected
(have the front end open at the first form) and even though this links to
the back-end files, there are no ldb files created.

This is so I know when it is safe to compact the back-end files without
going round to make sure everyone is logged off. User level security is in
place.

Thanks
Jeff
Dec 2 '05 #1
40 2913
Jeff,
I'm no expert but my understanding is that you can have the frontend op
and it will not affect the backend if the forms that are open are not bound
to a table from the backend. I'm pretty sure that if there is no lbd file
present for the backend, no-one will be connected to it.

Mark
"Jeff" <je************ @asken.com.au> wrote in message
news:43******** **************@ per-qv1-newsreader-01.iinet.net.au ...
I have a system on a network and want to determine if anyone is currently
connected to the back-end files.

An interesting twist is that I have noticed that some users can be
connected (have the front end open at the first form) and even though this
links to the back-end files, there are no ldb files created.

This is so I know when it is safe to compact the back-end files without
going round to make sure everyone is logged off. User level security is in
place.

Thanks
Jeff

Dec 2 '05 #2
TC
Why not just try to compact it & handle the error? If it works, it
worked. If it didn't, you can print a tailored message & then try again
later.

HTH,
TC

Dec 2 '05 #3
This used to work in the olden (access 97 days).

Private Function CanBeOpenedExcl usively(ByVal FullPath As String) As
Boolean
Dim d As Database
Dim p As PrivDBEngine
Set p = New PrivDBEngine
On Error Resume Next
Set d = p(0).OpenDataba se(FullPath, True)
CanBeOpenedExcl usively = Not (d Is Nothing)
p(0).Close
Set d = Nothing
Set p = Nothing
End Function

Dec 2 '05 #4
if there's no ldb on the back end then there are no table locks and the
databse can be compacted. Even if a user is logged into the front end,
they may not have any record locks as they have no tables, queries,
recordsets etc open to the backend. If the user tries to do something
while you are compacting they might get an error message and pick up
the phone and bark at you a little... but thats a fact of life as an
access administrator :)

a good trick to use is make a copy of the backend, compact the copy and
then quickly swap it for the old be... theres less of a time window
that way

always always always make a copy of the backend before compacting it on
the fly...

always!

Dec 2 '05 #5
"Jeff" <je************ @asken.com.au> wrote in
news:43******** **************@ per-qv1-newsreader-01.iinet.net.au :
I have a system on a network and want to determine if anyone is
currently connected to the back-end files.

An interesting twist is that I have noticed that some users can be
connected (have the front end open at the first form) and even
though this links to the back-end files, there are no ldb files
created.

This is so I know when it is safe to compact the back-end files
without going round to make sure everyone is logged off. User
level security is in place.


There are two methods:

1. use the LDBUSR.DLL. You should search the Microsoft Knowledge
Base for that file name.

2. use the ADO UserRoster function.

BTW, I would definitely want to check before attempting to compact,
rather than just raising the error and handling it, as TC suggests.

There are lots of things you could do with the user information,
such as message the users who are logged in and ask them to log out.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Dec 2 '05 #6
Ted
Jeff:
I have an application in which I just added a table to the Back End,
and code in the Front End which updates the BE Table to show who is
logged in and who is logged out of the application.
That of course isn't accurate if someone has just rebooted their
computer (in which case they would not have been marked as logged
out). So I am going to enter an On Timer event of my Main Menu form
(which only has buttons to open up other forms). The On Timer event,
which I think I will set for 5 minute intervals, will update the BE
table to show the last time it "checked in" with the BE to tell it they
are still logged in. That way if someone has not updated a field in the
table within a five minute time period, it can be assumed they are not
logged in.
I have noticed that when a user tries to update information on a form
that has a timer even on it, they are usually sent back to the first
field in the Tab Order on the form. This can be quite irritating. Since
I only use the Main Menu to show command buttons to open other forms,
and I HIDE the Main Menu rather than close it, the On Timer event will
fire for the Main Menu form and should not effect whatever form I am
working in. In fact I shall write that and check it out now, while I am
thinking about it.
In the BE table, I identify the computer updating its logon information
by using the computer's name, not the CurrentUser() which could be
Admin on the computer or the network logon name. My BE table serves to
control how many computers can use the application at any one time (for
licensing reinforcement).
Here is the BE table:
tblActivity
User txt 50 and Primary Key to avoid duplicate entries
LogDate Short Date
LogTime Short Time
Status txt 3 (either IN or OUT)
LastCheckIn Short Time

This code section Logs the user in when they open the application. Call
it from your Main Menu OnOpen event or when your Splash Screen opens.:
Dim intMaxUsers As Integer
Dim CRS1 As ADODB.Recordset
Dim strCmd As String
Dim intUsers As Integer
Dim intUserCount As Integer
Dim intFoundUser As Integer
intMaxUsers = CheckMaxLicUser s()
Set CRS1 = New ADODB.Recordset
CRS1.Open "tblActivit y", CurrentProject. Connection, adOpenKeyset,
adLockReadOnly
intUserCount = CRS1.RecordCoun t
If CRS1.RecordCoun t > 0 Then
CRS1.MoveLast
intUsers = CRS1.RecordCoun t
CRS1.MoveFirst
End If
While Not CRS1.EOF
If CRS1.Fields("Us er") = strUser Then
intFoundUser = 1
'MsgBox "Found User"
End If
CRS1.MoveNext
Wend
CRS1.Close
If intUserCount < intMaxUsers And intFoundUser = 0 Then
LogActivity = 1
CRS1.Open "tblActivit y", CurrentProject. Connection,
adOpenKeyset, adLockOptimisti c
CRS1.AddNew
CRS1.Fields("Us er") = strUser
CRS1.Fields("Lo gDate") = Format(Now(), "mm/dd/yyyy")
CRS1.Fields("Lo gTime") = Format(Now(), "hh:mm:ss")
CRS1.Fields("St atus") = "IN"
CRS1.Update
CRS1.Close
Else
If intUserCount > intMaxUser And intFoundUser = 0 Then
LogActivity = 0
Else
LogActivity = 3
strCmd = "SELECT * FROM tblActivity WHERE User = '" &
strUser & "'"
CRS1.Open strCmd, CurrentProject. Connection, adOpenKeyset,
adLockOptimisti c
CRS1.Fields("Lo gDate") = Format(Now(), "mm/dd/yyyy")
CRS1.Fields("Lo gTime") = Format(Now(), "hh:mm:ss")
CRS1.Fields("St atus") = "IN"
CRS1.Update
CRS1.Close
End If
End If
Set CRS1 = Nothing

The following code is in the OnTimer event of the Main Menu form:
OnTimer Event: Call UpdateUserActiv ity(fOSMachineN ame())
Function UpdateUserActiv ity(strUser As String) As Integer
Dim CRS1 As ADODB.Recordset
Dim strCmd As String

Set CRS1 = New ADODB.Recordset
strCmd = "SELECT * FROM tblActivity WHERE User = '" & strUser & "'"
CRS1.Open strCmd, CurrentProject. Connection, adOpenKeyset,
adLockOptimisti c
CRS1.Fields("La stCheckIn") = Format(Now(), "hh:mm:ss")
CRS1.Update
CRS1.Close
Set CRS1 = Nothing
End Function

I've also created a form bound to the tblActivity which show me all of
the computers that have logged in to the application (and therefore are
connected to the BE), what date and time they logged IN or OUT, and the
last time their computer checked in with the activity log.

Jeff wrote:
I have a system on a network and want to determine if anyone is currently
connected to the back-end files.

An interesting twist is that I have noticed that some users can be connected
(have the front end open at the first form) and even though this links to
the back-end files, there are no ldb files created.

This is so I know when it is safe to compact the back-end files without
going round to make sure everyone is logged off. User level security is in
place.

Thanks
Jeff


Dec 3 '05 #7
Ted
By the way, using this same Check IN and Check OUT method, you could
add a field to the tblActivity and modify the code that checks in to
look for a certain value in that field.
If a certain value is in the field, cause each user's application to
open up and form that will display a message telling the user to log
off immediately. If they are not at their computer during that time,
have the form time out and with the OnTimer event Quit the application.
That would automatically close each user's application within whatever
time periods you have set up for each function (Example: The update
activity function runs every five minutes and the time out form times
out in five minutes. At the most you will have to wait only ten minutes
from the time you issue to log out command until all of the computers
have shut down the application.)
Does that make any sense? It does to me, but sometimes it is difficult
to put ideas into words.

Dec 3 '05 #8
TC

David W. Fenton wrote:

There are two methods:

1. use the LDBUSR.DLL. You should search the Microsoft Knowledge
Base for that file name.

2. use the ADO UserRoster function.

There are three methods. The third is to attempt to compact it & trap
the error if one occurs.

TC

Dec 3 '05 #9
"TC" <aa**********@y ahoo.com> wrote in
news:11******** **************@ o13g2000cwo.goo glegroups.com:
David W. Fenton wrote:
There are two methods:

1. use the LDBUSR.DLL. You should search the Microsoft Knowledge
Base for that file name.

2. use the ADO UserRoster function.


There are three methods. The third is to attempt to compact it &
trap the error if one occurs.


That won't tell you who is using it, which was the original
question, and has utility in itself.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Dec 3 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4553
by: RickPowell | last post by:
I wrote a VB .NET Service to restart the computer when certain business rules are triggered (such as not being rebooted in x days, no users logged on, time is 1-3 am, etc.). I am currently using a sloppy technique of checking the Registry to determine if and who is logged on. I would like to use a Microsoft sanctioned best-practice method...
16
3403
by: Jm | last post by:
Hi All Is it possible to determine who is logged onto a machine from inside a service using code in vb.net ? I have found some code that seems to work under vb6, but doesnt under .NET ? Any help is greatly appreciated Thanks
0
7597
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7752
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7697
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5894
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1831
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
980
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.