Menu

[r5]: / trunk / source / DBVisualizer / UI / QueryForm.vb  Maximize  Restore  History

Download this file

62 lines (35 with data), 1.8 kB

 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
Imports System.Data.Common
Friend Class QueryForm
Private mSource As IDBConnectionProxy
Public Sub New(ByVal source As IDBConnectionProxy)
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
mSource = source
End Sub
Private Sub Execute()
Dim result As QueryResult
result = mSource.RunQuery(QueryTextBox.Text)
If result.Exception Is Nothing Then
ResultGrid.DataSource = result.ResultTable
MessageLabel.ForeColor = Drawing.Color.Black
MessageLabel.Text = String.Format("{0} {1} returned in {2}ms:", result.ResultTable.Rows.Count, IIf(result.ResultTable.Rows.Count = 1, "row", "rows"), result.QueryTime.TotalMilliseconds)
Else
ResultGrid.DataSource = Nothing
MessageLabel.ForeColor = Drawing.Color.Red
MessageLabel.Text = result.Exception.Message.Replace(ControlChars.NewLine, " - ")
End If
End Sub
Private Sub ExecuteButtonClickedHandler(ByVal sender As Object, ByVal e As EventArgs) Handles ExecuteButton.Click
Execute()
End Sub
Private Sub QueryForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
QueryTextBox.SelectionStart = QueryTextBox.Text.Length
End Sub
Private Sub QueryTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles QueryTextBox.KeyDown
'If e.KeyCode = Keys.Return Then Execute()
End Sub
Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseButton.Click
Me.Close()
End Sub
End Class