943,649 Members | Top Members by Rank

Ad:
Dec 4th, 2008
0

Trying to check a remote connection!

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Zermoth is offline Offline
8 posts
since Dec 2008
Dec 11th, 2008
0

Figured out part 1 any idea’s on rest

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Zermoth is offline Offline
8 posts
since Dec 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: disconnected Remote Users?
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Encrypting a .txt file through VB6





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC