Trying to check a remote connection!

Thread Solved

Join Date: Dec 2008
Posts: 8
Reputation: Zermoth is an unknown quantity at this point 
Solved Threads: 0
Zermoth's Avatar
Zermoth Zermoth is offline Offline
Newbie Poster

Trying to check a remote connection!

 
0
  #1
Dec 4th, 2008
Try to do 3 things.

The 1st see if a database exists in a certain location:
if it dose then connect.
else show error message.

The 2nd see if the database is open:
if open the display a message to the users that they are going to get disconnected.
pause for a length of time.
then disconnect them from the database.

The 3rd how to open the Database in exclusive mode.

Below my code and possible placing of extra code.

Writing with in Access 2003, and is a part of a unload download program.

Public Const RemoteDatabase As String = "\\RemoteDatabase\RemoteDatabase.mdb"
Public dbRemoteDatabase As New ADODB.Connection
Public rsTableRemote01 As New ADODB.Recordset
Public rsTableRemote02 As New ADODB.Recordset
Public rsTableRemote03 As New ADODB.Recordset
Public Const Table01 As String = "tblTable01"
Public Const Table02 As String = "tblTable02"
Public Const Table03 As String = "tblTable03"

Function OpenRemoteDatabase1()
If <try to see if the Database is there or not> = <true> then
If<anyone is connected to it> = <true> then
<Display message to Users that they are getting disconnected>
<Pause state 60 seconds>
<disconnect Users>
End If
If dbRemoteDatabase.State = 0 Then
dbRemoteDatabase.Open "Provider = microsoft.jet.oledb.4.0;data source=" & RemoteDatabase

rsTableRemote01.Open Table01, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
rsTableRemote02.Open Table02, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
rsTableRemote03.Open Table03, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
End If
Else
msgbox "Database not connected" & Chr(13) & Chr(10) & "Connect and re try" , vbCritical
DoCmd.Close
End If
End Function
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: Zermoth is an unknown quantity at this point 
Solved Threads: 0
Zermoth's Avatar
Zermoth Zermoth is offline Offline
Newbie Poster

Figured out part 1 any idea’s on rest

 
0
  #2
Dec 11th, 2008
Public sfso

Set sfso = CreateObject("Scripting.FileSystemObject")

If sfso.FileExists(RemoteDatabase) Then
If dbRemoteDatabase.State = 0 Then
dbRemoteDatabase.Open "Provider = microsoft.jet.oledb.4.0;data source=" & RemoteDatabase

rsTableRemote01.Open Table01, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
rsTableRemote02.Open Table02, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
rsTableRemote03.Open Table03, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
End If
Else
msgbox "Database not connected" & Chr(13) & Chr(10) & "Connect and re try" , vbCritical
DoCmd.Close
End If
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC