Modules.Database
This commit is contained in:
28
Modules.Database/App.config
Normal file
28
Modules.Database/App.config
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</configSections>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="EntityFramework.Firebird.FbConnectionFactory, EntityFramework.Firebird" />
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
|
||||
<provider invariantName="FirebirdSql.Data.FirebirdClient" type="EntityFramework.Firebird.FbProviderServices, EntityFramework.Firebird" />
|
||||
</providers>
|
||||
</entityFramework>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<remove invariant="FirebirdSql.Data.FirebirdClient" />
|
||||
<add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient" />
|
||||
</DbProviderFactories>
|
||||
</system.data>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -1,4 +1,167 @@
|
||||
Public Class Firebird
|
||||
Imports FirebirdSql.Data.FirebirdClient
|
||||
Public Class Firebird
|
||||
Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
|
||||
Public DBInitialized As Boolean = False
|
||||
Private _connectionEstablished As Boolean = False
|
||||
Private _connectionFailed As Boolean = False
|
||||
Private ReadOnly dataSource As String
|
||||
Private ReadOnly database As String
|
||||
Private ReadOnly user As String
|
||||
Private ReadOnly password As String
|
||||
Public CurrentFBDConnectionString As String = ""
|
||||
Public ReadOnly Property ConnectionString As String
|
||||
Public ReadOnly Property ConnectionEstablished As Boolean
|
||||
Get
|
||||
Return _connectionEstablished
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property ConnectionFailed As Boolean
|
||||
Get
|
||||
Return _connectionFailed
|
||||
End Get
|
||||
End Property
|
||||
Public Sub New(dataSource As String, database As String, user As String, password As String)
|
||||
ConnectionString = BuildConnectionString(dataSource, database, user, password)
|
||||
' Save connection credentials
|
||||
dataSource = dataSource
|
||||
database = database
|
||||
user = user
|
||||
password = password
|
||||
' Test the connection first
|
||||
Dim conn = Connect(ConnectionString)
|
||||
' If initial connection was successfully, close it
|
||||
conn?.Close()
|
||||
End Sub
|
||||
|
||||
Private Function Connect(ConnectionString As String) As FbConnection
|
||||
Try
|
||||
Dim conn = New FbConnection(ConnectionString)
|
||||
conn.Open()
|
||||
_connectionEstablished = True
|
||||
_connectionFailed = False
|
||||
Logger.Debug("Connection established!")
|
||||
Logger.Debug($"User: {user}")
|
||||
Logger.Debug($"DatabaseLocation: {database}")
|
||||
Logger.Debug($"DatabaseServer: {dataSource}")
|
||||
|
||||
Return conn
|
||||
Catch ex As Exception
|
||||
_connectionFailed = True
|
||||
_connectionEstablished = False
|
||||
Logger.Error(ex)
|
||||
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Builds a connectionstring from the provided arguments.
|
||||
''' </summary>
|
||||
''' <param name="dataSource">The database server where to connect to</param>
|
||||
''' <param name="database">The datasource, eg. the path of the FDB-file</param>
|
||||
''' <param name="user">The user used to connect to the database</param>
|
||||
''' <param name="password">The password of the connecting user</param>
|
||||
''' <returns>A connectionstring</returns>
|
||||
Private Function BuildConnectionString(dataSource As String, database As String, user As String, password As String) As String
|
||||
Dim connectionStringBuilder = New FbConnectionStringBuilder With {
|
||||
.DataSource = dataSource,
|
||||
.Database = database,
|
||||
.UserID = user,
|
||||
.Password = password
|
||||
}
|
||||
Return connectionStringBuilder.ConnectionString
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Executes a non-query command.
|
||||
''' </summary>
|
||||
''' <param name="sqlCommand">The command to execute</param>
|
||||
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
||||
Public Function NewExecuteNonQuery(sqlCommand As String) As Boolean
|
||||
Try
|
||||
Dim conn As FbConnection = Connect(ConnectionString)
|
||||
|
||||
If conn Is Nothing Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim transaction As FbTransaction = conn.BeginTransaction()
|
||||
Dim command As New FbCommand With {
|
||||
.CommandText = sqlCommand,
|
||||
.Connection = conn,
|
||||
.Transaction = transaction
|
||||
}
|
||||
command.ExecuteNonQuery()
|
||||
|
||||
transaction.Commit()
|
||||
conn.Close()
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, $"Error in ExecuteNonQuery while executing command: '{sqlCommand}'")
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Executes a sql query resulting in a scalar value.
|
||||
''' </summary>
|
||||
''' <param name="sqlQuery">The query to execute</param>
|
||||
''' <returns>The scalar value if the command was executed successfully. Nothing otherwise.</returns>
|
||||
Public Function GetExecuteScalar(sqlQuery As String) As Object
|
||||
Try
|
||||
Dim conn As FbConnection = Connect(ConnectionString)
|
||||
|
||||
If conn Is Nothing Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim transaction As FbTransaction = conn.BeginTransaction()
|
||||
Dim command As New FbCommand With {
|
||||
.CommandText = sqlQuery,
|
||||
.Connection = conn,
|
||||
.Transaction = transaction
|
||||
}
|
||||
Dim result As Object = command.ExecuteScalar()
|
||||
|
||||
transaction.Commit()
|
||||
conn.Close()
|
||||
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, $"Error in ReturnScalar while executing command: '{sqlQuery}'")
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Executes a sql query resulting in a table of values.
|
||||
''' </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 Function GetDatatable(sqlQuery As String) As DataTable
|
||||
Try
|
||||
Dim conn As FbConnection = Connect(ConnectionString)
|
||||
|
||||
If conn Is Nothing Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim command As New FbCommand With {
|
||||
.CommandText = sqlQuery,
|
||||
.Connection = conn
|
||||
}
|
||||
Dim adapter As New FbDataAdapter(command)
|
||||
Dim dt As New DataTable()
|
||||
|
||||
adapter.Fill(dt)
|
||||
conn.Close()
|
||||
|
||||
Return dt
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex, $"Error in ReturnDatatable while executing command: '{sqlQuery}'")
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Public Class SQLServer
|
||||
Public Class MSSQLServer
|
||||
Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
|
||||
Public DBInitialized As Boolean = False
|
||||
Public CurrentSQLConnectionString As String = ""
|
||||
Private CurrentSQLConnection As SqlClient.SqlConnection
|
||||
Public Sub New(CONSTRING As String)
|
||||
Init(CONSTRING)
|
||||
End Sub
|
||||
@@ -17,11 +18,38 @@ Public Class SQLServer
|
||||
DBInitialized = True
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
DBInitialized = False
|
||||
Logger.Error(ex)
|
||||
'clsLogger.Add("Error in DatabaseInit: " & ex.Message, True)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Private Function GetSQLConnection()
|
||||
Try
|
||||
If IsNothing(CurrentSQLConnection) Then
|
||||
Dim oSQLconnect As New SqlClient.SqlConnection
|
||||
oSQLconnect.ConnectionString = CurrentSQLConnectionString
|
||||
CurrentSQLConnection = oSQLconnect
|
||||
CurrentSQLConnection.Open()
|
||||
|
||||
Else
|
||||
If CurrentSQLConnection.State <> ConnectionState.Open Then
|
||||
Logger.Warn($"Actual ConnectionState is: '{CurrentSQLConnection.State.ToString}'")
|
||||
Try
|
||||
CurrentSQLConnection.Open()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Could not reconnect to database!")
|
||||
Return False
|
||||
End Try
|
||||
End If
|
||||
End If
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
''' <summary>
|
||||
''' Returns a datatable for a sql-statement
|
||||
''' </summary>
|
||||
@@ -31,17 +59,19 @@ Public Class SQLServer
|
||||
''' <remarks></remarks>
|
||||
Public Function GetDatatable(sqlcommand As String, Optional commandtimeout As Integer = 120) As DataTable
|
||||
Try
|
||||
Dim oSQLconnect As New SqlClient.SqlConnection
|
||||
Dim dt As DataTable = New DataTable()
|
||||
If GetSQLConnection() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oSQLCOmmand As SqlClient.SqlCommand
|
||||
oSQLconnect.ConnectionString = CurrentSQLConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
|
||||
oSQLCOmmand = CurrentSQLConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = sqlcommand
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(oSQLCOmmand)
|
||||
Dim dt As DataTable = New DataTable()
|
||||
adapter1.Fill(dt)
|
||||
oSQLconnect.Close()
|
||||
|
||||
Return dt
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
@@ -58,16 +88,17 @@ Public Class SQLServer
|
||||
''' <remarks></remarks>
|
||||
Public Function NewExecutenonQuery(executeStatement As String, Optional commandtimeout As Integer = 120) As Boolean
|
||||
Try
|
||||
Dim oSQLconnect As New SqlClient.SqlConnection
|
||||
If GetSQLConnection() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
'Dim oSQLconnect As New SqlClient.SqlConnection
|
||||
Dim oSQLCOmmand As SqlClient.SqlCommand
|
||||
oSQLconnect.ConnectionString = CurrentSQLConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
|
||||
oSQLCOmmand = CurrentSQLConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = executeStatement
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
oSQLCOmmand.ExecuteNonQuery()
|
||||
oSQLCOmmand.Dispose()
|
||||
oSQLconnect.Close()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
@@ -82,22 +113,21 @@ Public Class SQLServer
|
||||
''' <param name="commandtimeout">Optional Timeout</param>
|
||||
''' <remarks></remarks>
|
||||
Public Sub NewExecuteNonQueryAsync(executeStatement As String, Optional commandtimeout As Integer = 120)
|
||||
Dim oSQLconnect As New SqlClient.SqlConnection
|
||||
If GetSQLConnection() = False Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim oSQLCOmmand As SqlClient.SqlCommand
|
||||
Dim callback As New AsyncCallback(AddressOf Execute_non_Query_Async_Callback)
|
||||
Try
|
||||
oSQLconnect.ConnectionString = CurrentSQLConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand = CurrentSQLConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = executeStatement
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
oSQLCOmmand.BeginExecuteNonQuery(callback, oSQLCOmmand)
|
||||
oSQLCOmmand.Dispose()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Debug("executeStatement: " & executeStatement)
|
||||
Finally
|
||||
oSQLCOmmand.Dispose()
|
||||
oSQLconnect.Close()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -116,18 +146,16 @@ Public Class SQLServer
|
||||
Public Function NewExecuteScalar(executeStatement As String, Optional commandtimeout As Integer = 120)
|
||||
Dim result
|
||||
Try
|
||||
Dim oSQLconnect As New SqlClient.SqlConnection
|
||||
Dim oSQLCOmmand As SqlClient.SqlCommand
|
||||
oSQLconnect.ConnectionString = CurrentSQLConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
If GetSQLConnection() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oSQLCOmmand As SqlClient.SqlCommand
|
||||
oSQLCOmmand = CurrentSQLConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = executeStatement
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
result = oSQLCOmmand.ExecuteScalar()
|
||||
oSQLCOmmand.Dispose()
|
||||
oSQLconnect.Close()
|
||||
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
@@ -43,6 +43,18 @@
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.Firebird, Version=6.1.0.0, Culture=neutral, PublicKeyToken=42d22d092898e5f8, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.Firebird.6.1.0\lib\net452\EntityFramework.Firebird.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FirebirdSql.Data.FirebirdClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FirebirdSql.Data.FirebirdClient.6.0.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.5.8\lib\net45\NLog.dll</HintPath>
|
||||
@@ -51,6 +63,7 @@
|
||||
<HintPath>P:\Visual Studio Projekte\Bibliotheken\Oracle.ManagedDataAccess.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
@@ -77,7 +90,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Firebird.vb" />
|
||||
<Compile Include="Oracle.vb" />
|
||||
<Compile Include="SQLServer.vb" />
|
||||
<Compile Include="MSSQLServer.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
@@ -103,6 +116,7 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
|
||||
@@ -3,4 +3,133 @@ Public Class Oracle
|
||||
Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
|
||||
Public DBInitialized As Boolean = False
|
||||
Public CurrentOracleConnectionString As String = ""
|
||||
Public Sub New(CONSTRING As String)
|
||||
Init(CONSTRING)
|
||||
End Sub
|
||||
Public Function Init(CONSTRING As String)
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
oSQLconnect.ConnectionString = CONSTRING
|
||||
oSQLconnect.Open()
|
||||
oSQLconnect.Close()
|
||||
CurrentOracleConnectionString = CONSTRING
|
||||
DBInitialized = True
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
DBInitialized = False
|
||||
Logger.Error(ex)
|
||||
'clsLogger.Add("Error in DatabaseInit: " & ex.Message, True)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
''' <summary>
|
||||
''' Returns a datatable for a sql-statement
|
||||
''' </summary>
|
||||
''' <param name="sqlcommand">sqlcommand for datatable (select XYZ from TableORView)</param>
|
||||
''' <param name="commandtimeout">Optional Timeout</param>
|
||||
''' <returns>Returns a datatable</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function GetDatatable(sqlcommand As String, Optional commandtimeout As Integer = 120) As DataTable
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
oSQLconnect.ConnectionString = CurrentOracleConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand.CommandText = sqlcommand
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
Dim adapter1 As OracleDataAdapter = New OracleDataAdapter(oSQLCOmmand)
|
||||
Dim dt As DataTable = New DataTable()
|
||||
adapter1.Fill(dt)
|
||||
oSQLconnect.Close()
|
||||
Return dt
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Debug("sqlcommand: " & sqlcommand)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
''' <summary>
|
||||
''' Executes the passed sql-statement
|
||||
''' </summary>
|
||||
''' <param name="executeStatement">the sql statement</param>
|
||||
''' <param name="commandtimeout">Optional Timeout</param>
|
||||
''' <returns>Returns true if properly executed, else false</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function NewExecutenonQuery(executeStatement As String, Optional commandtimeout As Integer = 120) As Boolean
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
oSQLconnect.ConnectionString = CurrentOracleConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand.CommandText = executeStatement
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
oSQLCOmmand.ExecuteNonQuery()
|
||||
oSQLCOmmand.Dispose()
|
||||
oSQLconnect.Close()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Debug("executeStatement: " & executeStatement)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
''' <summary>
|
||||
''' Executes the passed sql-statement in asyncmode
|
||||
''' </summary>
|
||||
''' <param name="executeStatement">the sql statement</param>
|
||||
''' <param name="commandtimeout">Optional Timeout</param>
|
||||
''' <remarks></remarks>
|
||||
Public Sub NewExecuteNonQueryAsync(executeStatement As String, Optional commandtimeout As Integer = 120)
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
Dim callback As New AsyncCallback(AddressOf Execute_non_Query_Async_Callback)
|
||||
Try
|
||||
oSQLconnect.ConnectionString = CurrentOracleConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand.CommandText = executeStatement
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
oSQLCOmmand.ExecuteNonQuery()
|
||||
oSQLCOmmand.Dispose()
|
||||
oSQLconnect.Close()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Debug("executeStatement: " & executeStatement)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub Execute_non_Query_Async_Callback(ByVal result As IAsyncResult)
|
||||
Dim command As OracleCommand = CType(result.AsyncState, OracleCommand)
|
||||
Dim res = command.ExecuteNonQuery
|
||||
Logger.Info(String.Format("Finished executing Async database operation: {0}", command.CommandText))
|
||||
End Sub
|
||||
''' <summary>
|
||||
''' Executes the passed sql-statement as Scalar
|
||||
''' </summary>
|
||||
''' <param name="executeStatement">the sql statement</param>
|
||||
''' <param name="commandtimeout">Optional Timeout</param>
|
||||
''' <returns>Returns true if properly executed, else false</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function NewExecuteScalar(executeStatement As String, Optional commandtimeout As Integer = 120)
|
||||
Dim result
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
oSQLconnect.ConnectionString = CurrentOracleConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand.CommandText = executeStatement
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
result = oSQLCOmmand.ExecuteScalar()
|
||||
oSQLCOmmand.Dispose()
|
||||
oSQLconnect.Close()
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Debug("executeStatement: " & executeStatement)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
|
||||
<package id="EntityFramework.Firebird" version="6.1.0" targetFramework="net461" />
|
||||
<package id="FirebirdSql.Data.FirebirdClient" version="6.0.0" targetFramework="net461" />
|
||||
<package id="NLog" version="4.5.8" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user