• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Detecting a network failure.

Hi,

I'm making a Point of Sale program in VB 5.0, with a MS Access Database. My problem is I want a way to have an
event go off when the database is no longer availible (because of a network
failure). If this event went off it would be easy to start a restroration
procedure, instead of having to error protect every access to the database (all done with DAO).
Thanks,
Dave
vbpro@pacbell.net
0
vbpro
Asked:
vbpro
1 Solution
 
PC-AlexCommented:
I cannot imagine that there's an event that you can evaluate when the database is no more available. Who should fire it ? You'll always have to check availability on your own. Write one procedure with an "On error Goto" statement that contains a simple access to your database, called before every database access.
0
 
ChrisLewisCommented:
How about a Test in a Timer with a Global Variable for Database status?Something like this:+----------+----------+In GLobal.Bas+----------+----------+DIM giDatabaseAvailable as Integer+----------+----------+In Main.FRM+----------+----------+sub Timer1_Timer()  On Error Goto Timer1_Timer_Err  'Just a simple test to see if the Access File is available  If LEN$(DIR$(strDatabase)) = 0 THen    '0 Length means no file...    giDatabaseAvailable = False    'Here you could also do something like:    'Call FixNetworkSutff()  Else    giDatabaseAvailable = True  End ifTimer1_Timer_Exit:  Exit SubTimer1_Timer_Err:  Select case err    Case 76  'Invalid Directory (I think...)      giDatabaseAvailable = False    Case ELse      'Other bad things,      giDatabaseAvailable = False  End select  Resume Timer1_Timer_ExitEnd Sub+----------+----------+
Around any Database Call+----------+----------+
  IF giDatabaseAvailable THen    db.DoStuff  Else    MsgBox "Networks looks to be down."  ENd if

+----------+----------+
How about that???CHris  
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now