dbTalk Databases Forums  

Making Sure A Database Is Running

comp.databases.ms-access comp.databases.ms-access


Discuss Making Sure A Database Is Running in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Neil
 
Posts: n/a

Default Making Sure A Database Is Running - 05-21-2012 , 09:18 PM






I need to run a process using a timer. The process needs to be running all
day long. We are looking for a way to ensure that the program is running,
and, if not, then relaunch it.

Some thoughts I had were:

1) Find a utility that runs in the background and checks periodically if the
db is running, and, if not, relaunches it.

2) Write some code in Access VBA or in VB that checks to see if the database
is open, launches it if it doesn't, and then closes itself. The small
program could be launched from Windows Scheduler every 15 minutes or so.

3) Other.

#1 would be ideal. Anyone know of anything like that? I figure there must be
something like this, given the need to run processes continually.

#2 would be fine. But, while I know I can check if Access is running by
using GetObject, I don't know how I would then check to see if that specific
database is open (or if there are multiple instances of Access running).

Any ideas?

Thanks,

Neil

Reply With Quote
  #2  
Old   
Ron Paii
 
Posts: n/a

Default Re: Making Sure A Database Is Running - 05-22-2012 , 07:05 AM






"Neil" <neil.ginsberg+newsgroup (AT) gmail (DOT) com> wrote

Quote:
I need to run a process using a timer. The process needs to be running all
day long. We are looking for a way to ensure that the program is running,
and, if not, then relaunch it.

Some thoughts I had were:

1) Find a utility that runs in the background and checks periodically if
the db is running, and, if not, relaunches it.

2) Write some code in Access VBA or in VB that checks to see if the
database is open, launches it if it doesn't, and then closes itself. The
small program could be launched from Windows Scheduler every 15 minutes or
so.

3) Other.

#1 would be ideal. Anyone know of anything like that? I figure there must
be something like this, given the need to run processes continually.

#2 would be fine. But, while I know I can check if Access is running by
using GetObject, I don't know how I would then check to see if that
specific database is open (or if there are multiple instances of Access
running).

Any ideas?

Thanks,

Neil

If you are OK with Windows Scheduler, have it open you Access program and
have Access exit when done.

Reply With Quote
  #3  
Old   
Patrick Finucane
 
Posts: n/a

Default Re: Making Sure A Database Is Running - 05-22-2012 , 08:38 AM



On May 22, 7:05*am, "Ron Paii" <N... (AT) none (DOT) com> wrote:
Quote:
"Neil" <neil.ginsberg+newsgr... (AT) gmail (DOT) com> wrote in message

news:jpet2i$bme$1 (AT) dont-email (DOT) me...





I need to run a process using a timer. The process needs to be running all
day long. We are looking for a way to ensure that the program is running,
and, if not, then relaunch it.

Some thoughts I had were:

1) Find a utility that runs in the background and checks periodically if
the db is running, and, if not, relaunches it.

2) Write some code in Access VBA or in VB that checks to see if the
database is open, launches it if it doesn't, and then closes itself. The
small program could be launched from Windows Scheduler every 15 minutesor
so.

3) Other.

#1 would be ideal. Anyone know of anything like that? I figure there must
be something like this, given the need to run processes continually.

#2 would be fine. But, while I know I can check if Access is running by
using GetObject, I don't know how I would then check to see if that
specific database is open (or if there are multiple instances of Access
running).

Any ideas?

Thanks,

Neil

If you are OK with Windows Scheduler, have it open you Access program and
have Access exit when done.- Hide quoted text -

- Show quoted text -

Reply With Quote
  #4  
Old   
Patrick Finucane
 
Posts: n/a

Default Re: Making Sure A Database Is Running - 05-22-2012 , 08:49 AM



On May 21, 9:18*pm, "Neil" <neil.ginsberg+newsgr... (AT) gmail (DOT) com> wrote:
Quote:
I need to run a process using a timer. The process needs to be running all
day long. We are looking for a way to ensure that the program is running,
and, if not, then relaunch it.

Some thoughts I had were:

1) Find a utility that runs in the background and checks periodically if the
db is running, and, if not, relaunches it.

2) Write some code in Access VBA or in VB that checks to see if the database
is open, launches it if it doesn't, and then closes itself. The small
program could be launched from Windows Scheduler every 15 minutes or so.

3) Other.

#1 would be ideal. Anyone know of anything like that? I figure there mustbe
something like this, given the need to run processes continually.

#2 would be fine. But, while I know I can check if Access is running by
using GetObject, I don't know how I would then check to see if that specific
database is open (or if there are multiple instances of Access running).

Any ideas?

Thanks,

Neil
If I open the front end, I'll see an laccdb file created. If I open a
linked table, an laccdb file will be created for the backend. When I
close the table, the laccdb file closes in the backend, the front end
still remains. That is one method. To check for an laccdb. If it
does not exist, launch. However, the app could have closed
abnormally the laccdb file could still remain, With the OpenCurrent
database you could set the exclusive flag to True. If no error,
reopen. #2 is a good option I think if you want to roll your own.
..

Reply With Quote
  #5  
Old   
Neil
 
Posts: n/a

Default Re: Making Sure A Database Is Running - 05-23-2012 , 05:19 AM



"Ron Paii" <None (AT) none (DOT) com> wrote

Quote:

"Neil" <neil.ginsberg+newsgroup (AT) gmail (DOT) com> wrote in message
news:jpet2i$bme$1 (AT) dont-email (DOT) me...
I need to run a process using a timer. The process needs to be running
all day long. We are looking for a way to ensure that the program is
running, and, if not, then relaunch it.

Some thoughts I had were:

1) Find a utility that runs in the background and checks periodically if
the db is running, and, if not, relaunches it.

2) Write some code in Access VBA or in VB that checks to see if the
database is open, launches it if it doesn't, and then closes itself. The
small program could be launched from Windows Scheduler every 15 minutes
or so.

3) Other.

#1 would be ideal. Anyone know of anything like that? I figure there must
be something like this, given the need to run processes continually.

#2 would be fine. But, while I know I can check if Access is running by
using GetObject, I don't know how I would then check to see if that
specific database is open (or if there are multiple instances of Access
running).

Any ideas?

Thanks,

Neil


If you are OK with Windows Scheduler, have it open you Access program and
have Access exit when done.
Yes, that is the method we're currently using. Works fine. Only thing is,
the process has to be run every 5 minutes on a continual cycle. So my
concern was that continually opening and closing the Access database would,
over time, exhaust system resources. My thought was that just keeping the db
open and having it run on a timer loop would be better. But that would
require some sort of method to guarantee that it was relaunched if it
closed.

Reply With Quote
  #6  
Old   
Neil
 
Posts: n/a

Default Re: Making Sure A Database Is Running - 05-23-2012 , 05:23 AM



"Patrick Finucane" <patrickfinucanetx (AT) gmail (DOT) com> wrote

On May 21, 9:18 pm, "Neil" <neil.ginsberg+newsgr... (AT) gmail (DOT) com> wrote:
Quote:
I need to run a process using a timer. The process needs to be running all
day long. We are looking for a way to ensure that the program is running,
and, if not, then relaunch it.

Some thoughts I had were:

1) Find a utility that runs in the background and checks periodically if
the
db is running, and, if not, relaunches it.

2) Write some code in Access VBA or in VB that checks to see if the
database
is open, launches it if it doesn't, and then closes itself. The small
program could be launched from Windows Scheduler every 15 minutes or so.

3) Other.

#1 would be ideal. Anyone know of anything like that? I figure there must
be
something like this, given the need to run processes continually.

#2 would be fine. But, while I know I can check if Access is running by
using GetObject, I don't know how I would then check to see if that
specific
database is open (or if there are multiple instances of Access running).

Any ideas?

Thanks,

Neil
If I open the front end, I'll see an laccdb file created. If I open a
linked table, an laccdb file will be created for the backend. When I
close the table, the laccdb file closes in the backend, the front end
still remains. That is one method. To check for an laccdb. If it
does not exist, launch. However, the app could have closed
abnormally the laccdb file could still remain, With the OpenCurrent
database you could set the exclusive flag to True. If no error,
reopen. #2 is a good option I think if you want to roll your own.
..
===================

I like that idea of opening with exclusive access and checking for an error.
But, thinking it over, I'm not sure much would be accomplished by opening an
Access app to check if the other Access app is running, as opposed to just
launching and exiting the main Access app at set intervals through Windows
Scheduler (see my last post in this thread to Ron).

I suppose I could write the checking app as a VB app, which might be much
smaller and might use fewer resources.

Seem I'm chasing my tail here either way by opening a second app to check if
the first app is running.

Reply With Quote
  #7  
Old   
Ron Paii
 
Posts: n/a

Default Re: Making Sure A Database Is Running - 05-23-2012 , 07:07 AM



"Neil" <neil.ginsberg+newsgroup (AT) gmail (DOT) com> wrote

Quote:
"Ron Paii" <None (AT) none (DOT) com> wrote in message
news:jpfvdn$h1a$1 (AT) dont-email (DOT) me...


"Neil" <neil.ginsberg+newsgroup (AT) gmail (DOT) com> wrote in message
news:jpet2i$bme$1 (AT) dont-email (DOT) me...
I need to run a process using a timer. The process needs to be running
all day long. We are looking for a way to ensure that the program is
running, and, if not, then relaunch it.

Some thoughts I had were:

1) Find a utility that runs in the background and checks periodically if
the db is running, and, if not, relaunches it.

2) Write some code in Access VBA or in VB that checks to see if the
database is open, launches it if it doesn't, and then closes itself. The
small program could be launched from Windows Scheduler every 15 minutes
or so.

3) Other.

#1 would be ideal. Anyone know of anything like that? I figure there
must be something like this, given the need to run processes
continually.

#2 would be fine. But, while I know I can check if Access is running by
using GetObject, I don't know how I would then check to see if that
specific database is open (or if there are multiple instances of Access
running).

Any ideas?

Thanks,

Neil


If you are OK with Windows Scheduler, have it open you Access program and
have Access exit when done.

Yes, that is the method we're currently using. Works fine. Only thing is,
the process has to be run every 5 minutes on a continual cycle. So my
concern was that continually opening and closing the Access database
would, over time, exhaust system resources. My thought was that just
keeping the db open and having it run on a timer loop would be better. But
that would require some sort of method to guarantee that it was relaunched
if it closed.



I don't know the API calls, but you could have Access write it's PID to a
text file when started, then delete the file when exiting. Have a VBA,
VBscript, dotNet program check if the program with this PID is running.

Reply With Quote
  #8  
Old   
Patrick Finucane
 
Posts: n/a

Default Re: Making Sure A Database Is Running - 05-23-2012 , 08:35 AM



On May 23, 5:23*am, "Neil" <neil.ginsberg+newsgr... (AT) gmail (DOT) com> wrote:
Quote:
"Patrick Finucane" <patrickfinucan... (AT) gmail (DOT) com> wrote in message

news:6e4e279a-ea38-4de0-ac8b-bb35dcb8d942 (AT) m8g2000yqo (DOT) googlegroups.com...
On May 21, 9:18 pm, "Neil" <neil.ginsberg+newsgr... (AT) gmail (DOT) com> wrote:





I need to run a process using a timer. The process needs to be running all
day long. We are looking for a way to ensure that the program is running,
and, if not, then relaunch it.

Some thoughts I had were:

1) Find a utility that runs in the background and checks periodically if
the
db is running, and, if not, relaunches it.

2) Write some code in Access VBA or in VB that checks to see if the
database
is open, launches it if it doesn't, and then closes itself. The small
program could be launched from Windows Scheduler every 15 minutes or so..

3) Other.

#1 would be ideal. Anyone know of anything like that? I figure there must
be
something like this, given the need to run processes continually.

#2 would be fine. But, while I know I can check if Access is running by
using GetObject, I don't know how I would then check to see if that
specific
database is open (or if there are multiple instances of Access running)..

Any ideas?

Thanks,

Neil

If I open the front end, I'll see an laccdb file created. *If I open a
linked table, an laccdb file will be created for the backend. *When I
close the table, the laccdb file closes in the backend, the front end
still remains. *That is one method. *To check for an laccdb. *If it
does not exist, launch. * However, the app could have closed
abnormally the laccdb file could still remain, *With the OpenCurrent
database you could set the exclusive flag to *True. *If no error,
reopen. *#2 is a good option I think if you want to roll your own.
.
===================

I like that idea of opening with exclusive access and checking for an error.
But, thinking it over, I'm not sure much would be accomplished by openingan
Access app to check if the other Access app is running, as opposed to just
launching and exiting the main Access app at set intervals through Windows
Scheduler (see my last post in this thread to Ron).

I suppose I could write the checking app as a VB app, which might be much
smaller and might use fewer resources.

Seem I'm chasing my tail here either way by opening a second app to checkif
the first app is running.- Hide quoted text -

- Show quoted text -
My thought would be the second app is open at all times, runs on a
timer.

Reply With Quote
  #9  
Old   
Phil
 
Posts: n/a

Default Re: Making Sure A Database Is Running - 05-23-2012 , 10:15 AM



On 23/05/2012 13:07:32, "Ron Paii" wrote:
Quote:

"Neil" <neil.ginsberg+newsgroup (AT) gmail (DOT) com> wrote in message
news:jpidld$fl3$1 (AT) dont-email (DOT) me...

"Ron Paii" <None (AT) none (DOT) com> wrote in message
news:jpfvdn$h1a$1 (AT) dont-email (DOT) me...


"Neil" <neil.ginsberg+newsgroup (AT) gmail (DOT) com> wrote in message
news:jpet2i$bme$1 (AT) dont-email (DOT) me...
I need to run a process using a timer. The process needs to be running
all day long. We are looking for a way to ensure that the program is
running, and, if not, then relaunch it.

Some thoughts I had were:

1) Find a utility that runs in the background and checks periodically if
the db is running, and, if not, relaunches it.

2) Write some code in Access VBA or in VB that checks to see if the
database is open, launches it if it doesn't, and then closes itself. The
small program could be launched from Windows Scheduler every 15 minutes
or so.

3) Other.

#1 would be ideal. Anyone know of anything like that? I figure there
must be something like this, given the need to run processes
continually.

#2 would be fine. But, while I know I can check if Access is running by
using GetObject, I don't know how I would then check to see if that
specific database is open (or if there are multiple instances of Access
running).

Any ideas?

Thanks,

Neil


If you are OK with Windows Scheduler, have it open you Access program and
have Access exit when done.

Yes, that is the method we're currently using. Works fine. Only thing is,
the process has to be run every 5 minutes on a continual cycle. So my
concern was that continually opening and closing the Access database
would, over time, exhaust system resources. My thought was that just
keeping the db open and having it run on a timer loop would be better. But
that would require some sort of method to guarantee that it was relaunched
if it closed.




I don't know the API calls, but you could have Access write it's PID to a
text file when started, then delete the file when exiting. Have a VBA,
VBscript, dotNet program check if the program with this PID is running.


Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long

Function GetPID() As Long

GetPID = GetCurrentProcessId

End Function

Function fOSMachineName() As String
'Returns the computername

Dim lngLen As Long, lngX As Long
Dim strCompName As String

lngLen = 16
strCompName = String$(lngLen, 0)
lngX = apiGetComputerName(strCompName, lngLen)
If lngX <> 0 Then
fOSMachineName = Left$(strCompName, lngLen)
Else
fOSMachineName = ""
End If

End Function

Might help, but if Access crashes, the text file will still have the PID.
Might it be worth considering writing a date/ time to a text file, and
somehow checking that it isn't more tham 5 minutes out of date?

Phil

Reply With Quote
  #10  
Old   
Ron Paii
 
Posts: n/a

Default Re: Making Sure A Database Is Running - 05-23-2012 , 10:54 AM



"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 23/05/2012 13:07:32, "Ron Paii" wrote:


"Neil" <neil.ginsberg+newsgroup (AT) gmail (DOT) com> wrote in message
news:jpidld$fl3$1 (AT) dont-email (DOT) me...

"Ron Paii" <None (AT) none (DOT) com> wrote in message
news:jpfvdn$h1a$1 (AT) dont-email (DOT) me...


"Neil" <neil.ginsberg+newsgroup (AT) gmail (DOT) com> wrote in message
news:jpet2i$bme$1 (AT) dont-email (DOT) me...
I need to run a process using a timer. The process needs to be running
all day long. We are looking for a way to ensure that the program is
running, and, if not, then relaunch it.

Some thoughts I had were:

1) Find a utility that runs in the background and checks periodically
if
the db is running, and, if not, relaunches it.

2) Write some code in Access VBA or in VB that checks to see if the
database is open, launches it if it doesn't, and then closes itself.
The
small program could be launched from Windows Scheduler every 15
minutes
or so.

3) Other.

#1 would be ideal. Anyone know of anything like that? I figure there
must be something like this, given the need to run processes
continually.

#2 would be fine. But, while I know I can check if Access is running
by
using GetObject, I don't know how I would then check to see if that
specific database is open (or if there are multiple instances of
Access
running).

Any ideas?

Thanks,

Neil


If you are OK with Windows Scheduler, have it open you Access program
and
have Access exit when done.

Yes, that is the method we're currently using. Works fine. Only thing
is,
the process has to be run every 5 minutes on a continual cycle. So my
concern was that continually opening and closing the Access database
would, over time, exhaust system resources. My thought was that just
keeping the db open and having it run on a timer loop would be better.
But
that would require some sort of method to guarantee that it was
relaunched
if it closed.




I don't know the API calls, but you could have Access write it's PID to a
text file when started, then delete the file when exiting. Have a VBA,
VBscript, dotNet program check if the program with this PID is running.



Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long

Function GetPID() As Long

GetPID = GetCurrentProcessId

End Function

Function fOSMachineName() As String
'Returns the computername

Dim lngLen As Long, lngX As Long
Dim strCompName As String

lngLen = 16
strCompName = String$(lngLen, 0)
lngX = apiGetComputerName(strCompName, lngLen)
If lngX <> 0 Then
fOSMachineName = Left$(strCompName, lngLen)
Else
fOSMachineName = ""
End If

End Function

Might help, but if Access crashes, the text file will still have the PID.
Might it be worth considering writing a date/ time to a text file, and
somehow checking that it isn't more tham 5 minutes out of date?

Phil
The PID can't be out of date because it won't change unless the application
is started again. If Access crashes the PID will not be running, so the
checking program can restart the application which will update the file with
a new PID. If the file is missing because the Access application quit
normally, then the checking program can start the application, which will
create the file. The Access application could check for the file to verify
that it's not already running.

Reply With Quote
Reply




Thread Tools
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.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.