Index: TAOR rework/TAOR rework/databases/Cache/CacheMapper.vb =================================================================== diff -u -r1592 -r1595 --- TAOR rework/TAOR rework/databases/Cache/CacheMapper.vb (.../CacheMapper.vb) (revision 1592) +++ TAOR rework/TAOR rework/databases/Cache/CacheMapper.vb (.../CacheMapper.vb) (revision 1595) @@ -1,35 +1,24 @@ ' robin de bock 03/08/2017 Imports System.Data.Odbc -Imports System.Data.SqlClient Imports System.Text Module CacheMapper Private Const CONNECTIE_STRING As String = "DSN=Cache01Admin1; DRIVER={InterSystems ODBC}; SERVER=CACHE01;DATABASE=ADMIN1;UID=_SYSTEM;PWD=SYS" Private SQLConnection As OdbcConnection Private Sub connectToCache() - If SQLConnection Is Nothing Then - SQLConnection = New OdbcConnection(CONNECTIE_STRING) - End If - If Not SQLConnection.State = ConnectionState.Open Then - testConnection() - End If - End Sub - - Dim aantalPogingen As Integer = 0 - Dim MAXAANTALPOGINGEN As Integer = 3 - Private Sub testConnection() Try - SQLConnection.Open() - Catch ex As Exception - aantalPogingen += 1 - If aantalPogingen <= MAXAANTALPOGINGEN Then - MessageBox.Show("Connecteren met Caché... poging: " & aantalPogingen, "Probleem bij connecteren met Caché", MessageBoxButtons.OK, MessageBoxIcon.Warning) - Threading.Thread.Sleep(3000) - testConnection() + If SQLConnection Is Nothing Then + 'Connectie initialiseren. + SQLConnection = New OdbcConnection(CONNECTIE_STRING) End If - aantalPogingen = 0 - Throw New Exception("De Caché databank kan niet bereikt worden " & vbNewLine & vbNewLine & ex.Message) + 'Controleer of connectie status al open is. + If Not SQLConnection.State = ConnectionState.Open Then + 'ALs dit nog niet het geval is, open de connectie. + SQLConnection.Open() + End If + Catch ex As Exception + Throw New Exception($"De Caché databank kan niet bereikt worden: {vbNewLine}{ex.Message}") End Try End Sub