home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l407 / 5.ddi / SQL.FR_ / SQL.bin (.txt)
Encoding:
Visual Basic Form  |  1993-04-28  |  4.9 KB  |  176 lines

  1. VERSION 2.00
  2. Begin Form fSQL 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "SQL Statement"
  5.    ClientHeight    =   2880
  6.    ClientLeft      =   3690
  7.    ClientTop       =   1575
  8.    ClientWidth     =   5250
  9.    Height          =   3285
  10.    Icon            =   SQL.FRX:0000
  11.    Left            =   3630
  12.    LinkTopic       =   "Form1"
  13.    MDIChild        =   -1  'True
  14.    ScaleHeight     =   2863.353
  15.    ScaleMode       =   0  'User
  16.    ScaleWidth      =   5268
  17.    Top             =   1230
  18.    Width           =   5370
  19.    Begin CheckBox cPassThru 
  20.       BackColor       =   &H00C0C0C0&
  21.       Caption         =   "&SQL PassThrough"
  22.       Height          =   225
  23.       Left            =   210
  24.       TabIndex        =   4
  25.       Top             =   553
  26.       Width           =   2640
  27.    End
  28.    Begin CommandButton CreateQueryDefbtn 
  29.       Caption         =   "Create &QueryDef"
  30.       Height          =   375
  31.       Left            =   3045
  32.       TabIndex        =   3
  33.       Top             =   121
  34.       Visible         =   0   'False
  35.       Width           =   1695
  36.    End
  37.    Begin CommandButton ExecuteSQLButton 
  38.       Caption         =   "&Execute SQL"
  39.       Default         =   -1  'True
  40.       Enabled         =   0   'False
  41.       Height          =   372
  42.       Left            =   120
  43.       TabIndex        =   2
  44.       Top             =   120
  45.       Width           =   1332
  46.    End
  47.    Begin CommandButton ClearSQLButton 
  48.       Caption         =   "&Clear SQL"
  49.       Height          =   372
  50.       Left            =   1560
  51.       TabIndex        =   1
  52.       Top             =   120
  53.       Width           =   1332
  54.    End
  55.    Begin TextBox cSQLStatement 
  56.       BackColor       =   &H00FFFFFF&
  57.       Height          =   1932
  58.       Left            =   120
  59.       MultiLine       =   -1  'True
  60.       ScrollBars      =   2  'Vertical
  61.       TabIndex        =   0
  62.       Tag             =   "OL"
  63.       Top             =   840
  64.       Width           =   5052
  65.    End
  66. Option Explicit
  67. Sub ClearSQLButton_Click ()
  68.   cSQLStatement = ""
  69.   cSQLStatement.SetFocus
  70. End Sub
  71. Sub CreateQueryDefbtn_Click ()
  72.   Dim qn As String
  73.   Dim q As querydef
  74.   On Error GoTo CQDErr
  75.   qn = InputBox("Enter QueryDef Name:")
  76.   If qn = "" Then Exit Sub
  77.   Set q = gCurrentDB.CreateQueryDef(qn, cSQLStatement)
  78.   RefreshTables fTables.cTableList, True
  79.   GoTo CQDEnd
  80. CQDErr:
  81.   ShowError
  82.   Resume CQDEnd
  83. CQDEnd:
  84. End Sub
  85. Sub cSQLStatement_Change ()
  86.   If cSQLStatement <> "" Then
  87.     ExecuteSQLButton.Enabled = True
  88.   Else
  89.     ExecuteSQLButton.Enabled = False
  90.   End If
  91. End Sub
  92. Sub ExecuteSQLButton_Click ()
  93.    Dim RetSQL As Long
  94.    If cSQLStatement = "" Then Exit Sub
  95.    MsgBar "Executing SQL Statement", True
  96.    SetHourglass Me
  97.    If UCase(Mid(cSQLStatement, 1, 6)) = "SELECT" And InStr(UCase(cSQLStatement), " INTO ") = 0 Then
  98.      On Error GoTo SQLDSErr
  99. MakeDynaset:
  100.      gfFromSQL = True
  101.      'create a new dynaset form
  102.      gstDynaString = ""
  103.      On Error GoTo SQLDSErr
  104.      If VDMDI.cSingleRecord = True Then
  105.        Dim dsform1 As New fDynaset
  106.        dsform1.Show
  107.      ElseIf VDMDI.cDataCtl = True Then
  108.        Dim dsform2 As New fDataForm
  109.        dsform2.Show
  110.      Else
  111.        Dim dsform3 As New fGridFrm
  112.        dsform3.Show
  113.      End If
  114.    ElseIf UCase(cSQLStatement) = "LISTTABLES" Then
  115.      GoTo MakeDynaset
  116.    Else
  117.      On Error GoTo SQLErr
  118.      If gstDataType = "ODBC" Then
  119.        If UCase(Mid(cSQLStatement, 1, 4)) = "USE " Then
  120.          Beep
  121.          MsgBox "'Use' not allowed, try Open DataBase.", 48
  122.          GoTo SQLEnd
  123.        End If
  124.        RetSQL = gCurrentDB.ExecuteSQL(cSQLStatement)
  125.        If RetSQL > 0 Then
  126.          If gfTransPending Then gfDBChanged = True
  127.        End If
  128.        MsgBox CStr(RetSQL) + " row(s) Affected by SQL Statement.", 48
  129.      Else
  130.        gCurrentDB.Execute (cSQLStatement)
  131.        MsgBox "Execute of SQL Statement was Successful.", 48
  132.      End If
  133.    End If
  134.    GoTo SQLEnd
  135. SQLErr:
  136.    If Err = 3065 Then   'row returning so try to create dynaset
  137.      Resume MakeDynaset
  138.    End If
  139.    ShowError
  140.    Resume SQLEnd
  141. SQLDSErr:
  142.    Resume SQLEnd
  143. SQLEnd:
  144.    ResetMouse Me
  145.    MsgBar "", False
  146. End Sub
  147. Sub Form_Load ()
  148.   Dim x As Integer
  149.   cSQLStatement = GetINIString("SQLStatement", "")
  150.   x = Val(GetINIString("SQLWindowHeight", "3000"))
  151.   Height = x
  152.   x = Val(GetINIString("SQLWindowWidth", "5370"))
  153.   Width = x
  154.   x = Val(GetINIString("SQLWindowTop", "0"))
  155.   Top = x
  156.   x = Val(GetINIString("SQLWindowLeft", CStr(fTables.Left + fTables.Width)))
  157.   Left = x
  158. End Sub
  159. Sub Form_Paint ()
  160.   Outlines Me
  161. End Sub
  162. Sub Form_Resize ()
  163.   On Error Resume Next
  164.   If WindowState <> 1 Then
  165.     cSQLStatement.Width = Width - 320
  166.     cSQLStatement.Height = Height - 1450
  167.     Outlines Me
  168.     Me.Refresh
  169.   End If
  170. End Sub
  171. Sub Form_Unload (Cancel As Integer)
  172.   Dim x As Integer
  173.   Me.WindowState = 1
  174.   Cancel = True
  175. End Sub
  176.