/
OracleOperationsVisualBase.txt
66 lines (53 loc) · 1.61 KB
/
OracleOperationsVisualBase.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Translated from current csharp code.
==============================================================================
Public Class DataResults
Public Property DataTable() As DataTable
Public Property Success() As Boolean
Public Property Exception() As Exception
End Class
------------------------------------------------------------------------------
Option Infer On
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports Oracle.ManagedDataAccess.Client
Namespace DataGridViewDataTableOracle.Classes
''' <summary>
''' VB.NET Code in -> OracleOperationsVisualBase.txt
''' </summary>
Public Class OracleOperations
Public Shared ConnectionString As String = "TODO;"
''' <summary>
''' Read a table
''' </summary>
''' <returns>
''' <see cref="DataResults"/>
''' Which could be replaced with a named value tuple
''' </returns>
Public Shared Async Function ReadAllAsync() As Task(Of DataResults)
Dim dt = New DataTable()
Dim results = New DataResults() With {.Success = True}
Return Await Task.Run(Async Function()
Try
Using cn = New OracleConnection(ConnectionString)
Using cmd = cn.CreateCommand()
cmd.CommandText = "TODO"
cmd.CommandType = CommandType.Text
Await cn.OpenAsync()
dt.Load(Await cmd.ExecuteReaderAsync())
End Using
End Using
results.DataTable = dt
Return results
Catch ex As Exception
results.Exception = ex
results.Success = False
Return results
End Try
End Function)
End Function
End Class
End Namespace