Imports OracleInProcServer

Public Class frmSQLAreaOO4O
    Inherits System.Windows.Forms.Form

#Region " Windows フォーム デザイナで生成されたコード "

    Public Sub New()
        MyBase.New()

        ' この呼び出しは Windows フォーム デザイナで必要です。
        InitializeComponent()

        ' InitializeComponent() 呼び出しの後に初期化を追加します。

    End Sub

    ' Form は dispose をオーバーライドしてコンポーネント一覧を消去します。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    ' Windows フォーム デザイナで必要です。
    Private components As System.ComponentModel.IContainer

    ' メモ : 以下のプロシージャは、Windows フォーム デザイナで必要です。
    ' Windows フォーム デザイナを使って変更してください。  
    ' コード エディタは使用しないでください。
    Friend WithEvents txtSQL As System.Windows.Forms.TextBox
    Friend WithEvents mnuForm As System.Windows.Forms.MainMenu
    Friend WithEvents mnuVw As System.Windows.Forms.MenuItem
    Friend WithEvents mnuVwRefresh As System.Windows.Forms.MenuItem
    Friend WithEvents tmrLoad As System.Windows.Forms.Timer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.txtSQL = New System.Windows.Forms.TextBox()
        Me.mnuForm = New System.Windows.Forms.MainMenu()
        Me.mnuVw = New System.Windows.Forms.MenuItem()
        Me.mnuVwRefresh = New System.Windows.Forms.MenuItem()
        Me.tmrLoad = New System.Windows.Forms.Timer(Me.components)
        Me.SuspendLayout()
        '
        'txtSQL
        '
        Me.txtSQL.Dock = System.Windows.Forms.DockStyle.Fill
        Me.txtSQL.Multiline = True
        Me.txtSQL.Name = "txtSQL"
        Me.txtSQL.ReadOnly = True
        Me.txtSQL.ScrollBars = System.Windows.Forms.ScrollBars.Both
        Me.txtSQL.Size = New System.Drawing.Size(392, 233)
        Me.txtSQL.TabIndex = 6
        Me.txtSQL.Text = "txtSQL"
        Me.txtSQL.WordWrap = False
        '
        'mnuForm
        '
        Me.mnuForm.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuVw})
        '
        'mnuVw
        '
        Me.mnuVw.Index = 0
        Me.mnuVw.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuVwRefresh})
        Me.mnuVw.Text = "表示(&V)"
        '
        'mnuVwRefresh
        '
        Me.mnuVwRefresh.Index = 0
        Me.mnuVwRefresh.Shortcut = System.Windows.Forms.Shortcut.F5
        Me.mnuVwRefresh.Text = "最新の状態に更新(&R)"
        '
        'tmrLoad
        '
        Me.tmrLoad.Interval = 1
        '
        'frmSQLAreaOO4O
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
        Me.ClientSize = New System.Drawing.Size(392, 233)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtSQL})
        Me.Menu = Me.mnuForm
        Me.Name = "frmSQLAreaOO4O"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        Me.Text = "V$SQLAREA"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmSQLAreaOO4O_Load(ByVal sender As System.Object, _
                                    ByVal e As System.EventArgs) Handles MyBase.Load
        tmrLoad.Enabled = True
    End Sub
    Private Sub mnuVwRefresh_Click(ByVal sender As System.Object, _
                                   ByVal e As System.EventArgs) Handles mnuVwRefresh.Click

        tmrLoad.Enabled = True
    End Sub

    Private Sub tmrLoad_Tick(ByVal sender As System.Object, _
                             ByVal e As System.EventArgs) Handles tmrLoad.Tick
        Dim oraDs As OraDynaset
        Dim strSQL As String = "SELECT SQL_TEXT " & _
                                 "FROM V$SQLAREA " & _
                                "ORDER BY SQL_TEXT"
        Dim strErrText As String
        Dim strResult As String = ""

        tmrLoad.Enabled = False
        Try
            Me.Cursor = System.Windows.Forms.Cursors.WaitCursor()
            '
            oraDs = p_oraDb.CreateDynaset(strSQL, _
                                          dynOption.ORADYN_READONLY)
            Me.txtSQL.Text = ""
            Do While Not oraDs.EOF
                strResult = strResult & oraDs.Fields(0).value & vbCrLf
                oraDs.MoveNext()
            Loop
            Me.txtSQL.Text = strResult
        Catch
            strErrText = ErrorToString()
            MsgBox(strErrText, _
                   MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, _
                   Me.Text)
        Finally
            oraDs = Nothing
            Me.Cursor = System.Windows.Forms.Cursors.Default
        End Try
    End Sub
End Class
