home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l406 / 4.ddi / SQL.FR_ / SQL.bin (.txt)
Encoding:
Visual Basic Form  |  1992-10-21  |  3.2 KB  |  117 lines

  1. VERSION 2.00
  2. Begin Form fSQL 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "SQL Statement"
  5.    Height          =   3000
  6.    Icon            =   SQL.FRX:0000
  7.    Left            =   3630
  8.    LinkTopic       =   "Form1"
  9.    MDIChild        =   -1  'True
  10.    ScaleHeight     =   2580
  11.    ScaleMode       =   0  'User
  12.    ScaleWidth      =   5268
  13.    Top             =   1230
  14.    Width           =   5370
  15.    Begin CommandButton ExecuteSQLButton 
  16.       Caption         =   "&Execute SQL"
  17.       Default         =   -1  'True
  18.       Enabled         =   0   'False
  19.       Height          =   374
  20.       Left            =   120
  21.       TabIndex        =   2
  22.       Top             =   121
  23.       Width           =   1327
  24.    End
  25.    Begin CommandButton ClearSQLButton 
  26.       Caption         =   "&Clear SQL"
  27.       Height          =   374
  28.       Left            =   1555
  29.       TabIndex        =   1
  30.       Top             =   121
  31.       Width           =   1327
  32.    End
  33.    Begin TextBox cSQLStatement 
  34.       Height          =   1943
  35.       Left            =   120
  36.       MultiLine       =   -1  'True
  37.       ScrollBars      =   2  'Vertical
  38.       TabIndex        =   0
  39.       Top             =   603
  40.       Width           =   5035
  41.    End
  42. Option Explicit
  43. Sub ClearSQLButton_Click ()
  44.   cSQLStatement = ""
  45.   cSQLStatement.SetFocus
  46. End Sub
  47. Sub cSQLStatement_Change ()
  48.   If cSQLStatement <> "" Then
  49.     ExecuteSQLButton.Enabled = True
  50.   Else
  51.     ExecuteSQLButton.Enabled = False
  52.   End If
  53. End Sub
  54. Sub ExecuteSQLButton_Click ()
  55.    Dim RetSQL As Long
  56.    If cSQLStatement = "" Then Exit Sub
  57.    MsgBar "Executing SQL Statement", True
  58.    SetHourGlass Me
  59.    If UCase(Mid(cSQLStatement, 1, 6)) = "SELECT" Then
  60.      On Error GoTo SQLDSErr
  61.      gfFromSQL = True
  62.      'create a new dynaset form
  63.      gstDynaString = ""
  64.      If VDMDI.cSingleRecord = True Then
  65.        Dim dsform1 As New fDynaset
  66.        dsform1.Show
  67.      Else
  68.        Dim dsform2 As New fGridFrm
  69.        dsform2.Show
  70.      End If
  71.    Else
  72.      On Error GoTo SQLErr
  73.      If UCase(Mid(cSQLStatement, 1, 4)) = "USE " Then
  74.        Beep
  75.        MsgBox "'Use' not allowed, try Open DataBase.", 48
  76.        GoTo SQLEnd
  77.      End If
  78.      RetSQL = gCurrentDB.ExecuteSQL(cSQLStatement)
  79.      If RetSQL > 0 Then
  80.        If gfTransPending Then gfDBChanged = True
  81.      End If
  82.      MsgBox CStr(RetSQL) + " row(s) Affected by SQL Statement.", 48
  83.    End If
  84.    GoTo SQLEnd
  85. SQLErr:
  86.    ShowError
  87.    Resume SQLEnd
  88. SQLDSErr:
  89.    Resume SQLEnd
  90. SQLEnd:
  91.    ResetMouse Me
  92.    MsgBar "", False
  93. End Sub
  94. Sub Form_Load ()
  95.   Dim x As Integer
  96.   cSQLStatement = GetINIString("SQLStatement", "")
  97.   x = Val(GetINIString("SQLWindowHeight", "3000"))
  98.   Height = x
  99.   x = Val(GetINIString("SQLWindowWidth", "5370"))
  100.   Width = x
  101.   x = Val(GetINIString("SQLWindowTop", "0"))
  102.   Top = x
  103.   x = Val(GetINIString("SQLWindowLeft", CStr(fTables.Left + fTables.Width)))
  104.   Left = x
  105. End Sub
  106. Sub Form_Resize ()
  107.   If WindowState <> 1 Then
  108.     cSQLStatement.Width = Width - 320
  109.     cSQLStatement.Height = Height - 1150
  110.   End If
  111. End Sub
  112. Sub Form_Unload (Cancel As Integer)
  113.   Dim x As Integer
  114.   Me.WindowState = 1
  115.   Cancel = True
  116. End Sub
  117.