EDMI Service: WIP
This commit is contained in:
@@ -93,6 +93,7 @@
|
||||
<Compile Include="Constants.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="Firebird.vb" />
|
||||
<Compile Include="IDatabase.vb" />
|
||||
<Compile Include="ODBC.vb" />
|
||||
<Compile Include="Oracle.vb" />
|
||||
<Compile Include="MSSQLServer.vb" />
|
||||
|
||||
12
Modules.Database/IDatabase.vb
Normal file
12
Modules.Database/IDatabase.vb
Normal file
@@ -0,0 +1,12 @@
|
||||
Imports System.Data.Common
|
||||
|
||||
Public Interface IDatabase
|
||||
Function GetDatatable(SqlCommand As String, Timeout As Integer) As DataTable
|
||||
Function GetDatatable(SqlCommand As String) As DataTable
|
||||
|
||||
Function ExecuteNonQuery(SQLCommand As String, Timeout As Integer) As Boolean
|
||||
Function ExecuteNonQuery(SQLCommand As String) As Boolean
|
||||
|
||||
Function GetScalarValue(SQLQuery As String, Timeout As Integer) As Object
|
||||
Function GetScalarValue(SQLQuery As String) As Object
|
||||
End Interface
|
||||
@@ -1,7 +1,10 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Data.Common
|
||||
Imports System.Data.SqlClient
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class MSSQLServer
|
||||
Implements IDatabase
|
||||
|
||||
Public DBInitialized As Boolean = False
|
||||
Public CurrentSQLConnectionString As String = ""
|
||||
|
||||
@@ -40,7 +43,7 @@ Public Class MSSQLServer
|
||||
Dim oConnectionStringBuilder As New SqlConnectionStringBuilder() With {
|
||||
.DataSource = Server,
|
||||
.InitialCatalog = Database,
|
||||
.UserId = UserId,
|
||||
.UserID = UserId,
|
||||
.Password = Password
|
||||
}
|
||||
|
||||
@@ -89,7 +92,7 @@ Public Class MSSQLServer
|
||||
''' </summary>
|
||||
''' <param name="SqlCommand">sqlcommand for datatable (select XYZ from TableORView)</param>
|
||||
''' <returns>Returns a datatable</returns>
|
||||
Public Function GetDatatable(SqlCommand As String, Timeout As Integer) As DataTable
|
||||
Public Function GetDatatable(SqlCommand As String, Timeout As Integer) As DataTable Implements IDatabase.GetDatatable
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
@@ -113,7 +116,7 @@ Public Class MSSQLServer
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetDatatable(SqlCommand As String) As DataTable
|
||||
Public Function GetDatatable(SqlCommand As String) As DataTable Implements IDatabase.GetDatatable
|
||||
Return GetDatatable(SqlCommand, _Timeout)
|
||||
End Function
|
||||
|
||||
@@ -128,7 +131,7 @@ Public Class MSSQLServer
|
||||
Return ExecuteNonQuery(executeStatement)
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQuery(SQLCommand As String, Timeout As Integer) As Boolean
|
||||
Public Function ExecuteNonQuery(SQLCommand As String, Timeout As Integer) As Boolean Implements IDatabase.ExecuteNonQuery
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
@@ -149,7 +152,7 @@ Public Class MSSQLServer
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQuery(SQLCommand As String) As Boolean
|
||||
Public Function ExecuteNonQuery(SQLCommand As String) As Boolean Implements IDatabase.ExecuteNonQuery
|
||||
Return ExecuteNonQuery(SQLCommand, _Timeout)
|
||||
End Function
|
||||
|
||||
@@ -163,7 +166,7 @@ Public Class MSSQLServer
|
||||
Return GetScalarValue(ScalarSQL)
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(SQLQuery As String, Timeout As Integer) As Object
|
||||
Public Function GetScalarValue(SQLQuery As String, Timeout As Integer) As Object Implements IDatabase.GetScalarValue
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
@@ -184,10 +187,43 @@ Public Class MSSQLServer
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(SQLQuery As String) As Object
|
||||
Public Function GetScalarValue(SQLQuery As String) As Object Implements IDatabase.GetScalarValue
|
||||
Return GetScalarValue(SQLQuery, _Timeout)
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(SQLCommand As SqlCommand, OutputParameter As String, Timeout As Integer) As Object
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
If SQLCommand.CommandText.Contains(" ") Then
|
||||
SQLCommand.CommandType = CommandType.Text
|
||||
Else
|
||||
SQLCommand.CommandType = CommandType.StoredProcedure
|
||||
End If
|
||||
|
||||
Using oConnection As SqlConnection = GetSQLConnection()
|
||||
|
||||
SQLCommand.Connection = oConnection
|
||||
SQLCommand.Parameters(OutputParameter).Direction = ParameterDirection.Output
|
||||
SQLCommand.CommandTimeout = Timeout
|
||||
SQLCommand.ExecuteNonQuery()
|
||||
oConnection.Close()
|
||||
|
||||
Return SQLCommand.Parameters(OutputParameter).Value
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("SQLQuery: " & SQLCommand.CommandText)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(SQLCommand As SqlCommand, OutputParameter As String) As Object
|
||||
Return GetScalarValue(SQLCommand, OutputParameter, _Timeout)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Executes the passed sql-statement in asyncmode
|
||||
''' </summary>
|
||||
|
||||
Reference in New Issue
Block a user