Add RegexEditor, Improve Database Add Language
This commit is contained in:
5
Modules.Database/BaseClass.vb
Normal file
5
Modules.Database/BaseClass.vb
Normal file
@@ -0,0 +1,5 @@
|
||||
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
|
||||
5
Modules.Database/Constants.vb
Normal file
5
Modules.Database/Constants.vb
Normal file
@@ -0,0 +1,5 @@
|
||||
Public Class Constants
|
||||
Public Const PROVIDER_MSSQL = "MS-SQL"
|
||||
Public Const PROVIDER_ORACLE = "ORACLE"
|
||||
Public Const PROVIDER_ODBC = "ODBC"
|
||||
End Class
|
||||
@@ -90,6 +90,8 @@
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BaseClass.vb" />
|
||||
<Compile Include="Constants.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="Firebird.vb" />
|
||||
<Compile Include="ODBC.vb" />
|
||||
|
||||
@@ -46,6 +46,8 @@ 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
|
||||
@@ -183,7 +185,7 @@ Public Class Firebird
|
||||
''' <param name="Connection">The Firebird connection to use</param>
|
||||
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
||||
Public Function ExecuteNonQueryWithConnection(SqlCommand As String, Connection As FbConnection, Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction, Optional Transaction As FbTransaction = Nothing) As Boolean
|
||||
_logger.Debug("Executing Non-Query: {0}", SqlCommand)
|
||||
_Logger.Debug("Executing Non-Query: {0}", SqlCommand)
|
||||
|
||||
If Connection Is Nothing Then
|
||||
_Logger.Warn("Connection is nothing!")
|
||||
@@ -219,7 +221,7 @@ Public Class Firebird
|
||||
''' </summary>
|
||||
''' <param name="SqlCommand">The command to execute</param>
|
||||
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
||||
Public Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
||||
Public Overrides Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
||||
Dim oConnection As FbConnection = GetConnection()
|
||||
Dim oScalarValue As Object = ExecuteNonQueryWithConnection(SqlCommand, oConnection)
|
||||
oConnection.Close()
|
||||
@@ -234,7 +236,7 @@ Public Class Firebird
|
||||
''' <param name="Connection">The Firebird connection to use</param>
|
||||
''' <returns>The scalar value if the command was executed successfully. Nothing otherwise.</returns>
|
||||
Public Function GetScalarValueWithConnection(SqlQuery As String, Connection As FbConnection, Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction, Optional Transaction As FbTransaction = Nothing) As Object
|
||||
_logger.Debug("Fetching Scalar-Value: {0}", SqlQuery)
|
||||
_Logger.Debug("Fetching Scalar-Value: {0}", SqlQuery)
|
||||
|
||||
If Connection Is Nothing Then
|
||||
_Logger.Warn("Connection is nothing!")
|
||||
@@ -252,7 +254,7 @@ Public Class Firebird
|
||||
}
|
||||
oResult = oCommand.ExecuteScalar()
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex, $"Error in ReturnScalar while executing command: '{SqlQuery}'")
|
||||
_Logger.Error(ex, $"Error in ReturnScalar while executing command: '{SqlQuery}'")
|
||||
Throw ex
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
@@ -266,7 +268,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 Function GetScalarValue(SqlQuery As String) As Object
|
||||
Public Overrides Function GetScalarValue(SqlQuery As String) As Object
|
||||
Dim oConnection As FbConnection = GetConnection()
|
||||
Dim oScalarValue As Object = GetScalarValueWithConnection(SqlQuery, oConnection)
|
||||
oConnection.Close()
|
||||
@@ -281,7 +283,7 @@ Public Class Firebird
|
||||
''' <param name="Connection">The Firebird connection to use</param>
|
||||
''' <returns>A datatable containing the results if the command was executed successfully. Nothing otherwise.</returns>
|
||||
Public Function GetDatatableWithConnection(SqlQuery As String, Connection As FbConnection, Optional TransactionMode As TransactionMode = TransactionMode.NoTransaction, Optional Transaction As FbTransaction = Nothing) As DataTable
|
||||
_logger.Debug("Fetching Datatable: {0}", SqlQuery)
|
||||
_Logger.Debug("Fetching Datatable: {0}", SqlQuery)
|
||||
|
||||
If Connection Is Nothing Then
|
||||
_Logger.Warn("Connection is nothing!")
|
||||
@@ -302,7 +304,7 @@ Public Class Firebird
|
||||
|
||||
oAdapter.Fill(oDatatable)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex, $"Error in GetDatatableWithConnection while executing command: '{SqlQuery}'")
|
||||
_Logger.Error(ex, $"Error in GetDatatableWithConnection while executing command: '{SqlQuery}'")
|
||||
Throw ex
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
@@ -316,9 +318,9 @@ 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 Function GetDatatable(SqlQuery As String, Optional TransactionMode As TransactionMode = TransactionMode.NoTransaction) As DataTable
|
||||
Public Overrides Function GetDatatable(SqlQuery As String) As DataTable
|
||||
Dim oConnection As FbConnection = GetConnection()
|
||||
Dim oDatatable As DataTable = GetDatatableWithConnection(SqlQuery, oConnection, TransactionMode)
|
||||
Dim oDatatable As DataTable = GetDatatableWithConnection(SqlQuery, oConnection)
|
||||
oConnection.Close()
|
||||
|
||||
Return oDatatable
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
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
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, ConnectionString As String)
|
||||
Public Sub New(LogConfig As LogConfig, ConnectionString As String, Optional Timeout As Integer = 120)
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Timeout = Timeout
|
||||
|
||||
CurrentSQLConnectionString = ConnectionString
|
||||
|
||||
@@ -19,6 +24,31 @@ Public Class MSSQLServer
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Server As String, Database As String, UserId As String, Password As String, Optional Timeout As Integer = 120)
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Timeout = Timeout
|
||||
|
||||
CurrentSQLConnectionString = GetConnectionString(Server, Database, UserId, Password)
|
||||
|
||||
Try
|
||||
DBInitialized = TestCanConnect()
|
||||
Catch ex As Exception
|
||||
DBInitialized = False
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Shared Function GetConnectionString(Server As String, Database As String, UserId As String, Password As String) As String
|
||||
Dim oConnectionStringBuilder As New SqlConnectionStringBuilder() With {
|
||||
.DataSource = Server,
|
||||
.InitialCatalog = Database,
|
||||
.UserId = UserId,
|
||||
.Password = Password
|
||||
}
|
||||
|
||||
Return oConnectionStringBuilder.ToString
|
||||
End Function
|
||||
|
||||
Private Function TestCanConnect() As Boolean
|
||||
Try
|
||||
Dim oConnection As New SqlConnection(CurrentSQLConnectionString)
|
||||
@@ -41,14 +71,13 @@ Public Class MSSQLServer
|
||||
Return Nothing
|
||||
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="Timeout">Optional Timeout</param>
|
||||
''' <param name="SqlCommand">sqlcommand for datatable (select XYZ from TableORView)</param>
|
||||
''' <returns>Returns a datatable</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function GetDatatable(sqlcommand As String, Optional Timeout As Integer = 120) As DataTable
|
||||
Public Overrides Function GetDatatable(SqlCommand As String) As DataTable
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
@@ -56,8 +85,8 @@ Public Class MSSQLServer
|
||||
|
||||
Using oConnection = GetSQLConnection()
|
||||
Using oSQLCOmmand = oConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = sqlcommand
|
||||
oSQLCOmmand.CommandTimeout = Timeout
|
||||
oSQLCOmmand.CommandText = SqlCommand
|
||||
oSQLCOmmand.CommandTimeout = _Timeout
|
||||
|
||||
Dim dt As DataTable = New DataTable()
|
||||
Dim oAdapter As SqlDataAdapter = New SqlDataAdapter(oSQLCOmmand)
|
||||
@@ -67,23 +96,23 @@ Public Class MSSQLServer
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Debug("sqlcommand: " & sqlcommand)
|
||||
_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="Timeout">Optional Timeout</param>
|
||||
''' <returns>Returns true if properly executed, else false</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function NewExecutenonQuery(executeStatement As String, Optional Timeout As Integer = 120) As Boolean
|
||||
Public Function NewExecutenonQuery(executeStatement As String) As Boolean
|
||||
_Logger.Warn("NewExecutenonQuery is deprecated. Use ExecuteNonQuery instead.")
|
||||
Return ExecuteNonQuery(executeStatement, Timeout)
|
||||
Return ExecuteNonQuery(executeStatement)
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQuery(SQLCommand As String, Optional Timeout As Integer = 120) As Boolean
|
||||
Public Overrides Function ExecuteNonQuery(SQLCommand As String) As Boolean
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
@@ -92,7 +121,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
|
||||
@@ -108,15 +137,13 @@ Public Class MSSQLServer
|
||||
''' Executes the passed sql-statement as Scalar
|
||||
''' </summary>
|
||||
''' <param name="ScalarSQL">the sql statement</param>
|
||||
''' <param name="Timeout">Optional Timeout</param>
|
||||
''' <returns>Returns true if properly executed, else false</returns>
|
||||
''' <remarks></remarks>
|
||||
Public Function NewExecuteScalar(ScalarSQL As String, Optional Timeout As Integer = 120) As Object
|
||||
Public Function NewExecuteScalar(ScalarSQL As String) As Object
|
||||
_Logger.Warn("NewExecuteScalar is deprecated. Use GetScalarValue instead.")
|
||||
Return GetScalarValue(ScalarSQL, Timeout)
|
||||
Return GetScalarValue(ScalarSQL)
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(SQLQuery As String, Optional Timeout As Integer = 120) As Object
|
||||
Public Overrides Function GetScalarValue(SQLQuery As String) As Object
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
@@ -125,7 +152,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
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class ODBC
|
||||
Inherits BaseClass
|
||||
|
||||
Private _Logger As Logger
|
||||
Private _LogConfig As LogConfig
|
||||
|
||||
@@ -86,7 +88,7 @@ Public Class ODBC
|
||||
''' </summary>
|
||||
''' <param name="SqlCommand">The command to execute</param>
|
||||
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
||||
Public Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
||||
Public Overrides Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
||||
Dim oConnection As OdbcConnection = GetConnection()
|
||||
Dim oScalarValue As Object = ExecuteNonQueryWithConnection(SqlCommand, oConnection)
|
||||
oConnection.Close()
|
||||
@@ -126,7 +128,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 Function GetScalarValue(SqlQuery As String) As Object
|
||||
Public Overrides Function GetScalarValue(SqlQuery As String) As Object
|
||||
Dim oConnection As OdbcConnection = GetConnection()
|
||||
Dim oDatatable As DataTable = GetDatatableWithConnection(SqlQuery, oConnection)
|
||||
oConnection.Close()
|
||||
@@ -169,7 +171,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 Function GetDatatable(SqlQuery As String) As DataTable
|
||||
Public Overrides Function GetDatatable(SqlQuery As String) As DataTable
|
||||
Dim oConnection As OdbcConnection = GetConnection()
|
||||
Dim oDatatable As DataTable = GetDatatableWithConnection(SqlQuery, oConnection)
|
||||
oConnection.Close()
|
||||
|
||||
@@ -1,35 +1,53 @@
|
||||
Imports Oracle.ManagedDataAccess.Client
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports Oracle.ManagedDataAccess.Client
|
||||
|
||||
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)
|
||||
|
||||
Private _Timeout As Integer
|
||||
Private _Logger As Logger
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, ConnectionString As String, Optional Timeout As Integer = 120)
|
||||
_Timeout = Timeout
|
||||
_Logger = LogConfig.GetLogger()
|
||||
|
||||
CurrentOracleConnectionString = ConnectionString
|
||||
DBInitialized = TestCanConnect(CurrentOracleConnectionString)
|
||||
End Sub
|
||||
Public Function Init(CONSTRING As String)
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Server As String, Database As String, UserId As String, Password As String, Optional Timeout As Integer = 120)
|
||||
_Timeout = Timeout
|
||||
_Logger = LogConfig.GetLogger()
|
||||
|
||||
CurrentOracleConnectionString = GetConnectionString(Server, Database, UserId, Password)
|
||||
DBInitialized = TestCanConnect(CurrentOracleConnectionString)
|
||||
End Sub
|
||||
|
||||
Private Function TestCanConnect(ConnectionString As String) As Boolean
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
oSQLconnect.ConnectionString = CONSTRING
|
||||
oSQLconnect.ConnectionString = ConnectionString
|
||||
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)
|
||||
_Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Shared Function GetConnectionString(Server As String, Database As String, UserId As String, Password As String) As String
|
||||
Dim oConnectionString = $"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={Server})(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME={Database})));User Id={UserId};Password={Password};"
|
||||
Return oConnectionString
|
||||
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
|
||||
Public Function GetDatatable(sqlcommand As String) As DataTable
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
@@ -37,15 +55,15 @@ Public Class Oracle
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand.CommandText = sqlcommand
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
oSQLCOmmand.CommandTimeout = _Timeout
|
||||
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)
|
||||
_Logger.Error(ex)
|
||||
_Logger.Debug("sqlcommand: " & sqlcommand)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
@@ -53,10 +71,8 @@ Public Class Oracle
|
||||
''' 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
|
||||
Public Function NewExecutenonQuery(executeStatement As String) As Boolean
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
@@ -64,55 +80,24 @@ Public Class Oracle
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand.CommandText = executeStatement
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
oSQLCOmmand.CommandTimeout = _Timeout
|
||||
oSQLCOmmand.ExecuteNonQuery()
|
||||
oSQLCOmmand.Dispose()
|
||||
oSQLconnect.Close()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Debug("executeStatement: " & executeStatement)
|
||||
_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)
|
||||
''' <returns>Returns the scalarvalue</returns>
|
||||
Public Function NewExecuteScalar(executeStatement As String)
|
||||
Dim result
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
@@ -121,15 +106,15 @@ Public Class Oracle
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand.CommandText = executeStatement
|
||||
oSQLCOmmand.CommandTimeout = commandtimeout
|
||||
oSQLCOmmand.CommandTimeout = _Timeout
|
||||
result = oSQLCOmmand.ExecuteScalar()
|
||||
oSQLCOmmand.Dispose()
|
||||
oSQLconnect.Close()
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Debug("executeStatement: " & executeStatement)
|
||||
Return Nothing
|
||||
_Logger.Error(ex)
|
||||
_Logger.Debug("executeStatement: " & executeStatement)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user