Database: remove baseclass
This commit is contained in:
parent
718c77ccdd
commit
64a195018a
@ -1,5 +0,0 @@
|
||||
Public MustInherit Class BaseClass
|
||||
Public MustOverride Function GetDatatable(SqlCommand As String) As DataTable
|
||||
Public MustOverride Function GetScalarValue(SqlCommand As String) As Object
|
||||
Public MustOverride Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
||||
End Class
|
||||
@ -90,7 +90,6 @@
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BaseClass.vb" />
|
||||
<Compile Include="Constants.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="Firebird.vb" />
|
||||
|
||||
@ -46,8 +46,6 @@ Imports DigitalData.Modules.Logging
|
||||
''' REMARKS: If the connection fails due to "wrong username or password", the cause might be that the server harddrive is full..
|
||||
''' </summary>
|
||||
Public Class Firebird
|
||||
Inherits BaseClass
|
||||
|
||||
Private _Logger As Logger
|
||||
Private _LogConfig As LogConfig
|
||||
Private _connectionServer As String
|
||||
@ -221,7 +219,7 @@ Public Class Firebird
|
||||
''' </summary>
|
||||
''' <param name="SqlCommand">The command to execute</param>
|
||||
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
||||
Public Overrides Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
||||
Public Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
||||
Dim oConnection As FbConnection = GetConnection()
|
||||
Dim oScalarValue As Object = ExecuteNonQueryWithConnection(SqlCommand, oConnection)
|
||||
oConnection.Close()
|
||||
@ -268,7 +266,7 @@ Public Class Firebird
|
||||
''' </summary>
|
||||
''' <param name="SqlQuery">The query to execute</param>
|
||||
''' <returns>The scalar value if the command was executed successfully. Nothing otherwise.</returns>
|
||||
Public Overrides Function GetScalarValue(SqlQuery As String) As Object
|
||||
Public Function GetScalarValue(SqlQuery As String) As Object
|
||||
Dim oConnection As FbConnection = GetConnection()
|
||||
Dim oScalarValue As Object = GetScalarValueWithConnection(SqlQuery, oConnection)
|
||||
oConnection.Close()
|
||||
@ -304,7 +302,8 @@ Public Class Firebird
|
||||
|
||||
oAdapter.Fill(oDatatable)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex, $"Error in GetDatatableWithConnection while executing command: '{SqlQuery}'")
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("Error in GetDatatableWithConnection while executing command: '{0}'", SqlQuery)
|
||||
Throw ex
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
@ -318,11 +317,17 @@ Public Class Firebird
|
||||
''' </summary>
|
||||
''' <param name="SqlQuery">The query to execute</param>
|
||||
''' <returns>A datatable containing the results if the command was executed successfully. Nothing otherwise.</returns>
|
||||
Public Overrides Function GetDatatable(SqlQuery As String) As DataTable
|
||||
Dim oConnection As FbConnection = GetConnection()
|
||||
Dim oDatatable As DataTable = GetDatatableWithConnection(SqlQuery, oConnection)
|
||||
oConnection.Close()
|
||||
Public Function GetDatatable(SqlQuery As String, Optional TransactionMode As TransactionMode = TransactionMode.NoTransaction, Optional Transaction As FbTransaction = Nothing) As DataTable
|
||||
Try
|
||||
Dim oConnection As FbConnection = GetConnection()
|
||||
Dim oDatatable As DataTable = GetDatatableWithConnection(SqlQuery, oConnection, TransactionMode, Transaction)
|
||||
oConnection.Close()
|
||||
|
||||
Return oDatatable
|
||||
Return oDatatable
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("Error in GetDatatable while executing command: '{0}'", SqlQuery)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@ -2,13 +2,11 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class MSSQLServer
|
||||
Inherits BaseClass
|
||||
|
||||
Public DBInitialized As Boolean = False
|
||||
Public CurrentSQLConnectionString As String = ""
|
||||
|
||||
Private _Timeout As Integer
|
||||
Private _Logger As Logger
|
||||
Private ReadOnly _Timeout As Integer
|
||||
Private ReadOnly _Logger As Logger
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, ConnectionString As String, Optional Timeout As Integer = 120)
|
||||
_Logger = LogConfig.GetLogger()
|
||||
@ -77,7 +75,7 @@ Public Class MSSQLServer
|
||||
''' </summary>
|
||||
''' <param name="SqlCommand">sqlcommand for datatable (select XYZ from TableORView)</param>
|
||||
''' <returns>Returns a datatable</returns>
|
||||
Public Overrides Function GetDatatable(SqlCommand As String) As DataTable
|
||||
Public Function GetDatatable(SqlCommand As String, Timeout As Integer) As DataTable
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
@ -86,7 +84,7 @@ Public Class MSSQLServer
|
||||
Using oConnection = GetSQLConnection()
|
||||
Using oSQLCOmmand = oConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = SqlCommand
|
||||
oSQLCOmmand.CommandTimeout = _Timeout
|
||||
oSQLCOmmand.CommandTimeout = Timeout
|
||||
|
||||
Dim dt As DataTable = New DataTable()
|
||||
Dim oAdapter As SqlDataAdapter = New SqlDataAdapter(oSQLCOmmand)
|
||||
@ -101,6 +99,10 @@ Public Class MSSQLServer
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetDatatable(SqlCommand As String) As DataTable
|
||||
Return GetDatatable(SqlCommand, _Timeout)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Executes the passed sql-statement
|
||||
''' </summary>
|
||||
@ -112,7 +114,7 @@ Public Class MSSQLServer
|
||||
Return ExecuteNonQuery(executeStatement)
|
||||
End Function
|
||||
|
||||
Public Overrides Function ExecuteNonQuery(SQLCommand As String) As Boolean
|
||||
Public Function ExecuteNonQuery(SQLCommand As String, Timeout As Integer) As Boolean
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
@ -121,7 +123,7 @@ Public Class MSSQLServer
|
||||
Using oConnection = GetSQLConnection()
|
||||
Using oSQLCOmmand = oConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = SQLCommand
|
||||
oSQLCOmmand.CommandTimeout = _Timeout
|
||||
oSQLCOmmand.CommandTimeout = Timeout
|
||||
oSQLCOmmand.ExecuteNonQuery()
|
||||
Return True
|
||||
End Using
|
||||
@ -133,6 +135,10 @@ Public Class MSSQLServer
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQuery(SQLCommand As String) As Boolean
|
||||
Return ExecuteNonQuery(SQLCommand, _Timeout)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Executes the passed sql-statement as Scalar
|
||||
''' </summary>
|
||||
@ -143,7 +149,7 @@ Public Class MSSQLServer
|
||||
Return GetScalarValue(ScalarSQL)
|
||||
End Function
|
||||
|
||||
Public Overrides Function GetScalarValue(SQLQuery As String) As Object
|
||||
Public Function GetScalarValue(SQLQuery As String, Timeout As Integer) As Object
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
@ -152,7 +158,7 @@ Public Class MSSQLServer
|
||||
Using oConnection As SqlConnection = GetSQLConnection()
|
||||
Using oSQLCOmmand = oConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = SQLQuery
|
||||
oSQLCOmmand.CommandTimeout = _Timeout
|
||||
oSQLCOmmand.CommandTimeout = Timeout
|
||||
Dim oResult As Object = oSQLCOmmand.ExecuteScalar()
|
||||
Return oResult
|
||||
End Using
|
||||
@ -163,6 +169,10 @@ Public Class MSSQLServer
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(SQLQuery As String) As Object
|
||||
Return GetScalarValue(SQLQuery, _Timeout)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Executes the passed sql-statement in asyncmode
|
||||
''' </summary>
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class ODBC
|
||||
Inherits BaseClass
|
||||
|
||||
Private _Logger As Logger
|
||||
Private _LogConfig As LogConfig
|
||||
|
||||
@ -88,7 +86,7 @@ Public Class ODBC
|
||||
''' </summary>
|
||||
''' <param name="SqlCommand">The command to execute</param>
|
||||
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
||||
Public Overrides Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
||||
Public Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
||||
Dim oConnection As OdbcConnection = GetConnection()
|
||||
Dim oScalarValue As Object = ExecuteNonQueryWithConnection(SqlCommand, oConnection)
|
||||
oConnection.Close()
|
||||
@ -128,7 +126,7 @@ Public Class ODBC
|
||||
''' </summary>
|
||||
''' <param name="SqlQuery">The query to execute</param>
|
||||
''' <returns>A datatable containing the results if the command was executed successfully. Nothing otherwise.</returns>
|
||||
Public Overrides Function GetScalarValue(SqlQuery As String) As Object
|
||||
Public Function GetScalarValue(SqlQuery As String) As Object
|
||||
Dim oConnection As OdbcConnection = GetConnection()
|
||||
Dim oDatatable As DataTable = GetDatatableWithConnection(SqlQuery, oConnection)
|
||||
oConnection.Close()
|
||||
@ -171,7 +169,7 @@ Public Class ODBC
|
||||
''' </summary>
|
||||
''' <param name="SqlQuery">The query to execute</param>
|
||||
''' <returns>A datatable containing the results if the command was executed successfully. Nothing otherwise.</returns>
|
||||
Public Overrides Function GetDatatable(SqlQuery As String) As DataTable
|
||||
Public Function GetDatatable(SqlQuery As String) As DataTable
|
||||
Dim oConnection As OdbcConnection = GetConnection()
|
||||
Dim oDatatable As DataTable = GetDatatableWithConnection(SqlQuery, oConnection)
|
||||
oConnection.Close()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user