home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / PVb5.0 / VB / SAMPLES / VISDATA / SQL.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-01-12  |  5.7 KB  |  175 lines

  1. VERSION 5.00
  2. Begin VB.Form frmSQL 
  3.    Caption         =   "SQL 
  4.    ClientHeight    =   2880
  5.    ClientLeft      =   3690
  6.    ClientTop       =   1575
  7.    ClientWidth     =   5130
  8.    BeginProperty Font 
  9.       Name            =   "
  10.       Size            =   9
  11.       Charset         =   134
  12.       Weight          =   400
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    HelpContextID   =   2016144
  18.    Icon            =   "SQL.frx":0000
  19.    LinkTopic       =   "Form1"
  20.    LockControls    =   -1  'True
  21.    MDIChild        =   -1  'True
  22.    ScaleHeight     =   2863.353
  23.    ScaleMode       =   0  'User
  24.    ScaleWidth      =   5147.588
  25.    ShowInTaskbar   =   0   'False
  26.    Begin VB.CommandButton cmdSaveQueryDef 
  27.       Caption         =   "
  28. (&S)"
  29.       Height          =   375
  30.       Left            =   3375
  31.       MaskColor       =   &H00000000&
  32.       TabIndex        =   3
  33.       Top             =   30
  34.       Visible         =   0   'False
  35.       Width           =   1695
  36.    End
  37.    Begin VB.CommandButton cmdExecuteSQL 
  38.       Caption         =   "
  39. (&E)"
  40.       Default         =   -1  'True
  41.       Enabled         =   0   'False
  42.       Height          =   375
  43.       Left            =   15
  44.       MaskColor       =   &H00000000&
  45.       TabIndex        =   1
  46.       Top             =   30
  47.       Width           =   1575
  48.    End
  49.    Begin VB.CommandButton cmdClearSQL 
  50.       Caption         =   "
  51. (&C)"
  52.       Height          =   375
  53.       Left            =   1695
  54.       MaskColor       =   &H00000000&
  55.       TabIndex        =   2
  56.       Top             =   30
  57.       Width           =   1575
  58.    End
  59.    Begin VB.TextBox txtSQLStatement 
  60.       BackColor       =   &H00FFFFFF&
  61.       Height          =   2175
  62.       Left            =   15
  63.       MultiLine       =   -1  'True
  64.       ScrollBars      =   2  'Vertical
  65.       TabIndex        =   0
  66.       Top             =   435
  67.       Width           =   5055
  68.    End
  69. Attribute VB_Name = "frmSQL"
  70. Attribute VB_GlobalNameSpace = False
  71. Attribute VB_Creatable = False
  72. Attribute VB_PredeclaredId = True
  73. Attribute VB_Exposed = False
  74. Option Explicit
  75. '>>>>>>>>>>>>>>>>>>>>>>>>
  76. Const FORMCAPTION = "SQL 
  77. Const BUTTON1 = "
  78. (&E)"
  79. Const BUTTON2 = "
  80. (&C)"
  81. Const BUTTON3 = "
  82. (&S)"
  83. Const MSG1 = "
  84. Const MSG2 = "
  85. Const MSG3 = "
  86.  SQL 
  87. Const MSG4 = "
  88. Const MSG5 = "
  89. '>>>>>>>>>>>>>>>>>>>>>>>>
  90. Private Sub cmdClearSQL_Click()
  91.   txtSQLStatement.Text = vbNullString
  92.   txtSQLStatement.SetFocus
  93. End Sub
  94. Private Sub cmdSaveQueryDef_Click()
  95.   On Error GoTo SQDErr
  96.   Dim sQueryName As String
  97.   Dim sTmp As String
  98.   Dim qdNew As QueryDef
  99.   If Not gnodDBNode Is Nothing Then
  100.     If gnodDBNode.Tag = QUERY_STR Then
  101.       '
  102.       If MsgBox(MSG1 & " '" & gnodDBNode.Text & "'?", vbYesNo + vbQuestion) = vbYes Then
  103.         '
  104.         'SQL 
  105.         gdbCurrentDB.QueryDefs(gnodDBNode.Text).SQL = Me.txtSQLStatement.Text
  106.         Exit Sub
  107.       End If
  108.     End If
  109.   End If
  110.   sQueryName = InputBox(MSG2)
  111.   If Len(sQueryName) = 0 Then Exit Sub
  112.   If DupeTableName(sQueryName) Then
  113.     Exit Sub
  114.   End If
  115.   Set qdNew = gdbCurrentDB.CreateQueryDef(sQueryName)
  116.   If MsgBox(MSG3, vbYesNo + vbQuestion + vbDefaultButton2) = vbYes Then
  117.     sTmp = InputBox(MSG4)
  118.     If Len(sTmp) > 0 Then
  119.       qdNew.Connect = sTmp
  120.       If MsgBox(MSG5, vbYesNo + vbQuestion) = vbNo Then
  121.         qdNew.ReturnsRecords = False
  122.       End If
  123.     End If
  124.   End If
  125.   qdNew.SQL = txtSQLStatement.Text
  126.   gdbCurrentDB.QueryDefs.Refresh
  127.   RefreshTables Nothing
  128.   Exit Sub
  129. SQDErr:
  130.   ShowError
  131. End Sub
  132. Private Sub Form_Unload(Cancel As Integer)
  133.  sql 
  134.  INI 
  135. '  If InStr(frmSQL.txtSQLStatement.Text, Chr(13)) = 0 Then
  136.     SaveSetting APP_CATEGORY, App.Title, "SQLStatement", frmSQL.txtSQLStatement.Text
  137. '  End If
  138.   If frmSQL.WindowState = vbNormal Then
  139.     SaveSetting APP_CATEGORY, App.Title, "SQLWindowTop", frmSQL.Top
  140.     SaveSetting APP_CATEGORY, App.Title, "SQLWindowLeft", frmSQL.Left
  141.     SaveSetting APP_CATEGORY, App.Title, "SQLWindowWidth", frmSQL.Width
  142.     SaveSetting APP_CATEGORY, App.Title, "SQLWindowHeight", frmSQL.Height
  143.   End If
  144. End Sub
  145. Private Sub txtSQLStatement_Change()
  146.   cmdExecuteSQL.Enabled = Len(txtSQLStatement.Text) > 0
  147. End Sub
  148. Private Sub cmdExecuteSQL_Click()
  149.   If Len(txtSQLStatement.Text) = 0 Then Exit Sub
  150.   OpenQuery txtSQLStatement.Text, True
  151. End Sub
  152. Private Sub Form_Load()
  153.   Me.Caption = FORMCAPTION
  154.   cmdExecuteSQL.Caption = BUTTON1
  155.   cmdClearSQL.Caption = BUTTON2
  156.   cmdSaveQueryDef.Caption = BUTTON3
  157.   txtSQLStatement.Text = GetINIString("SQLStatement", vbNullString)
  158.   Me.Height = Val(GetINIString("SQLWindowHeight", "3000"))
  159.   Me.Width = Val(GetINIString("SQLWindowWidth", "5370"))
  160.   Me.Top = Val(GetINIString("SQLWindowTop", "0"))
  161.   Me.Left = Val(GetINIString("SQLWindowLeft", "3850"))
  162. End Sub
  163. Private Sub Form_Resize()
  164.   On Error Resume Next
  165.   If WindowState <> vbMinimized Then
  166.     txtSQLStatement.Width = Me.ScaleWidth - (txtSQLStatement.Left * 2)
  167.     txtSQLStatement.Height = Me.ScaleHeight - (txtSQLStatement.Top + 50)
  168.   End If
  169. End Sub
  170. Private Sub txtSQLStatement_DragDrop(Source As Control, X As Single, Y As Single)
  171.   If Source = frmDatabase.tvDatabase Then
  172.     frmSQL.txtSQLStatement.Text = gdbCurrentDB.QueryDefs(gnodDBNode.Text).SQL
  173.   End If
  174. End Sub
  175.