Trying to check a remote connection!
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Thread Solved
![]() |
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
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
Public sfso
Set sfso = CreateObject("Scripting.FileSystemObject")
If sfso.FileExists(RemoteDatabase) ThenIf dbRemoteDatabase.State = 0 ThenElsedbRemoteDatabase.Open "Provider = microsoft.jet.oledb.4.0;data source=" & RemoteDatabaseEnd If
rsTableRemote01.Open Table01, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
rsTableRemote02.Open Table02, dbRemoteDatabase, adOpenDynamic, adLockOptimistic
rsTableRemote03.Open Table03, dbRemoteDatabase, adOpenDynamic, adLockOptimisticmsgbox "Database not connected" & Chr(13) & Chr(10) & "Connect and re try" , vbCriticalEnd If
DoCmd.Close
![]() |
Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Remote Computer Shutdown (Windows NT / 2000 / XP / 2003)
- Updated : Simple ASP.Net Login Page (ASP.NET)
- Setting up a remote desktop connection (IT Professionals' Lounge)
- no more connections can be made to this remote computer (Windows NT / 2000 / XP / 2003)
- weird remote tcp connection (Viruses, Spyware and other Nasties)
- xp remote desktop across wan/lan (Windows NT / 2000 / XP / 2003)
- Obtain Remote Assistance by Sending an E-mail Message in Windows XP (Windows tips 'n' tweaks)
- Remote Desktop Connection (Windows NT / 2000 / XP / 2003)
- Obtain Remote Assistance by Sending an E-mail Message in Windows XP (Windows tips 'n' tweaks)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: disconnected Remote Users?
- Next Thread: Encrypting a .txt file through VB6
•
•
•
•
Views: 664 | Replies: 1 | Currently Viewing: 1 (0 members and 1 guests)





Linear Mode