From 33bea6fcb7d5f5cd2287a5288a4bce5180311052 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 5 Sep 2018 14:28:06 +0200 Subject: [PATCH] WIP: Update Firebird --- Modules.Database/Firebird.vb | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Modules.Database/Firebird.vb b/Modules.Database/Firebird.vb index c648695b..d125ad0c 100644 --- a/Modules.Database/Firebird.vb +++ b/Modules.Database/Firebird.vb @@ -47,6 +47,7 @@ Imports System.Text.RegularExpressions ''' Public Class Firebird Private _logger As Logger + Private _logFactory As LogFactory Private _connectionServer As String Private _connectionDatabase As String Private _connectionUsername As String @@ -64,7 +65,6 @@ Public Class Firebird End Get End Property - ''' ''' ''' @@ -76,27 +76,29 @@ Public Class Firebird ''' Public Sub New(LogFactory As LogFactory, Datasource As String, Database As String, User As String, Password As String) _logger = LogFactory.GetCurrentClassLogger() + _logFactory = LogFactory - ' Test the connection first Dim oConnectionString = GetConnectionString(Datasource, Database, User, Password) - Dim oConnection = GetConnection(oConnectionString) - ' If initial connection was successfully, close it - oConnection?.Close() - - If oConnection Is Nothing Then - Throw New Exceptions.DatabaseException() - End If _connectionServer = Datasource _connectionDatabase = Database _connectionUsername = User _connectionPassword = Password _ConnectionString = oConnectionString + + ' Test the connection + Dim oConnection = GetConnection() + ' If initial connection was successfully, close it + oConnection?.Close() + + If oConnection Is Nothing Then + Throw New Exceptions.DatabaseException() + End If End Sub - Private Function GetConnection(ConnectionString As String) As FbConnection + Public Function GetConnection() As FbConnection Try - Dim oConnection = New FbConnection(ConnectionString) + Dim oConnection = New FbConnection(_ConnectionString) oConnection.Open() _ConnectionEstablished = True _ConnectionFailed = False @@ -135,7 +137,7 @@ Public Class Firebird ''' True, if command was executed sucessfully. Otherwise false. Public Function ExecuteNonQuery(SqlCommand As String) As Boolean Try - Dim oConnection As FbConnection = GetConnection(ConnectionString) + Dim oConnection As FbConnection = GetConnection() If oConnection Is Nothing Then Return False @@ -165,7 +167,7 @@ Public Class Firebird ''' The scalar value if the command was executed successfully. Nothing otherwise. Public Function GetScalarValue(SqlQuery As String) As Object Try - Dim oConnection As FbConnection = GetConnection(ConnectionString) + Dim oConnection As FbConnection = GetConnection() If oConnection Is Nothing Then Return Nothing @@ -196,7 +198,7 @@ Public Class Firebird ''' A datatable containing the results if the command was executed successfully. Nothing otherwise. Public Function GetDatatable(SqlQuery As String) As DataTable Try - Dim oConnection As FbConnection = GetConnection(ConnectionString) + Dim oConnection As FbConnection = GetConnection() If oConnection Is Nothing Then Return Nothing