|
分類:[.NET 全般]
VB.NETの質問です。
よろしくお願いします。
class1
Private Sub Display()
Dim BindingSource1 As New BindingSource
BindingSource1.DataSource = OracleOperat.GetIncetance.Display("SELECT * from D_SQLTEST1") ←←←ここでNULLエラーがでます。
DataGridView1.DataSource = BindingSource1.DataSource
end Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Display()
End Sub
class2(OracleOperat)
Imports Oracle.ManagedDataAccess.Client
Imports Oracle.ManagedDataAccess.Types
Private Shared incetance As OracleOperat
'接続子
Private Const pConnectionString As String = "接続省略"
'接続用
Protected Shared Property OraConnect As OracleConnection = Nothing
' 接続
Public Shared Function GetIncetance() As OracleOperat
If OraConnect IsNot Nothing Then
OraConnect = New OracleConnection()
OraConnect.Open()
End If
Return incetance
End Function
''' <summary>
''' データベースを表示する
''' </summary>
''' <param name="SQL"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Function Display(ByVal SQL As String) As DataTable
'コマンド設定
Dim cmd As New OracleCommand
cmd.CommandText = SQL
cmd.Connection = OraConnect
'アダプタ
Dim oraAdapter As New OracleDataAdapter
oraAdapter = New OracleDataAdapter(cmd.CommandText, pConnectionString)
'読み込み
Dim Table As New DataTable()
oraAdapter.Fill(Table)
Return Table
End Function
|