WIP: Update Firebird
This commit is contained in:
parent
720b6955fd
commit
33bea6fcb7
@ -47,6 +47,7 @@ Imports System.Text.RegularExpressions
|
|||||||
''' </summary>
|
''' </summary>
|
||||||
Public Class Firebird
|
Public Class Firebird
|
||||||
Private _logger As Logger
|
Private _logger As Logger
|
||||||
|
Private _logFactory As LogFactory
|
||||||
Private _connectionServer As String
|
Private _connectionServer As String
|
||||||
Private _connectionDatabase As String
|
Private _connectionDatabase As String
|
||||||
Private _connectionUsername As String
|
Private _connectionUsername As String
|
||||||
@ -64,7 +65,6 @@ Public Class Firebird
|
|||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
'''
|
'''
|
||||||
''' </summary>
|
''' </summary>
|
||||||
@ -76,27 +76,29 @@ Public Class Firebird
|
|||||||
''' <exception cref="Exceptions.DatabaseException"></exception>
|
''' <exception cref="Exceptions.DatabaseException"></exception>
|
||||||
Public Sub New(LogFactory As LogFactory, Datasource As String, Database As String, User As String, Password As String)
|
Public Sub New(LogFactory As LogFactory, Datasource As String, Database As String, User As String, Password As String)
|
||||||
_logger = LogFactory.GetCurrentClassLogger()
|
_logger = LogFactory.GetCurrentClassLogger()
|
||||||
|
_logFactory = LogFactory
|
||||||
|
|
||||||
' Test the connection first
|
|
||||||
Dim oConnectionString = GetConnectionString(Datasource, Database, User, Password)
|
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
|
_connectionServer = Datasource
|
||||||
_connectionDatabase = Database
|
_connectionDatabase = Database
|
||||||
_connectionUsername = User
|
_connectionUsername = User
|
||||||
_connectionPassword = Password
|
_connectionPassword = Password
|
||||||
_ConnectionString = oConnectionString
|
_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
|
End Sub
|
||||||
|
|
||||||
Private Function GetConnection(ConnectionString As String) As FbConnection
|
Public Function GetConnection() As FbConnection
|
||||||
Try
|
Try
|
||||||
Dim oConnection = New FbConnection(ConnectionString)
|
Dim oConnection = New FbConnection(_ConnectionString)
|
||||||
oConnection.Open()
|
oConnection.Open()
|
||||||
_ConnectionEstablished = True
|
_ConnectionEstablished = True
|
||||||
_ConnectionFailed = False
|
_ConnectionFailed = False
|
||||||
@ -135,7 +137,7 @@ Public Class Firebird
|
|||||||
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
||||||
Public Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
Public Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
||||||
Try
|
Try
|
||||||
Dim oConnection As FbConnection = GetConnection(ConnectionString)
|
Dim oConnection As FbConnection = GetConnection()
|
||||||
|
|
||||||
If oConnection Is Nothing Then
|
If oConnection Is Nothing Then
|
||||||
Return False
|
Return False
|
||||||
@ -165,7 +167,7 @@ Public Class Firebird
|
|||||||
''' <returns>The scalar value if the command was executed successfully. Nothing otherwise.</returns>
|
''' <returns>The scalar value if the command was executed successfully. Nothing otherwise.</returns>
|
||||||
Public Function GetScalarValue(SqlQuery As String) As Object
|
Public Function GetScalarValue(SqlQuery As String) As Object
|
||||||
Try
|
Try
|
||||||
Dim oConnection As FbConnection = GetConnection(ConnectionString)
|
Dim oConnection As FbConnection = GetConnection()
|
||||||
|
|
||||||
If oConnection Is Nothing Then
|
If oConnection Is Nothing Then
|
||||||
Return Nothing
|
Return Nothing
|
||||||
@ -196,7 +198,7 @@ Public Class Firebird
|
|||||||
''' <returns>A datatable containing the results if the command was executed successfully. Nothing otherwise.</returns>
|
''' <returns>A datatable containing the results if the command was executed successfully. Nothing otherwise.</returns>
|
||||||
Public Function GetDatatable(SqlQuery As String) As DataTable
|
Public Function GetDatatable(SqlQuery As String) As DataTable
|
||||||
Try
|
Try
|
||||||
Dim oConnection As FbConnection = GetConnection(ConnectionString)
|
Dim oConnection As FbConnection = GetConnection()
|
||||||
|
|
||||||
If oConnection Is Nothing Then
|
If oConnection Is Nothing Then
|
||||||
Return Nothing
|
Return Nothing
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user