home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_2_1994.iso / 00202 / s / disk4 / sql.fr_ / sql.bin
Text File  |  1993-04-28  |  5KB  |  206 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. End
  67. Option Explicit
  68.  
  69. Sub ClearSQLButton_Click ()
  70.   cSQLStatement = ""
  71.   cSQLStatement.SetFocus
  72. End Sub
  73.  
  74. Sub CreateQueryDefbtn_Click ()
  75.   Dim qn As String
  76.   Dim q As querydef
  77.  
  78.   On Error GoTo CQDErr
  79.  
  80.   qn = InputBox("Enter QueryDef Name:")
  81.   If qn = "" Then Exit Sub
  82.  
  83.   Set q = gCurrentDB.CreateQueryDef(qn, cSQLStatement)
  84.   RefreshTables fTables.cTableList, True
  85.  
  86.   GoTo CQDEnd
  87.  
  88. CQDErr:
  89.   ShowError
  90.   Resume CQDEnd
  91.  
  92. CQDEnd:
  93.  
  94. End Sub
  95.  
  96. Sub cSQLStatement_Change ()
  97.   If cSQLStatement <> "" Then
  98.     ExecuteSQLButton.Enabled = True
  99.   Else
  100.     ExecuteSQLButton.Enabled = False
  101.   End If
  102. End Sub
  103.  
  104. Sub ExecuteSQLButton_Click ()
  105.    Dim RetSQL As Long
  106.  
  107.    If cSQLStatement = "" Then Exit Sub
  108.  
  109.    MsgBar "Executing SQL Statement", True
  110.    SetHourglass Me
  111.    If UCase(Mid(cSQLStatement, 1, 6)) = "SELECT" And InStr(UCase(cSQLStatement), " INTO ") = 0 Then
  112.      On Error GoTo SQLDSErr
  113. MakeDynaset:
  114.      gfFromSQL = True
  115.      'create a new dynaset form
  116.      gstDynaString = ""
  117.      On Error GoTo SQLDSErr
  118.      If VDMDI.cSingleRecord = True Then
  119.        Dim dsform1 As New fDynaset
  120.        dsform1.Show
  121.      ElseIf VDMDI.cDataCtl = True Then
  122.        Dim dsform2 As New fDataForm
  123.        dsform2.Show
  124.      Else
  125.        Dim dsform3 As New fGridFrm
  126.        dsform3.Show
  127.      End If
  128.    ElseIf UCase(cSQLStatement) = "LISTTABLES" Then
  129.      GoTo MakeDynaset
  130.    Else
  131.      On Error GoTo SQLErr
  132.      If gstDataType = "ODBC" Then
  133.        If UCase(Mid(cSQLStatement, 1, 4)) = "USE " Then
  134.          Beep
  135.          MsgBox "'Use' not allowed, try Open DataBase.", 48
  136.          GoTo SQLEnd
  137.        End If
  138.        RetSQL = gCurrentDB.ExecuteSQL(cSQLStatement)
  139.        If RetSQL > 0 Then
  140.          If gfTransPending Then gfDBChanged = True
  141.        End If
  142.        MsgBox CStr(RetSQL) + " row(s) Affected by SQL Statement.", 48
  143.      Else
  144.        gCurrentDB.Execute (cSQLStatement)
  145.        MsgBox "Execute of SQL Statement was Successful.", 48
  146.      End If
  147.  
  148.    End If
  149.  
  150.    GoTo SQLEnd
  151.  
  152. SQLErr:
  153.    If Err = 3065 Then   'row returning so try to create dynaset
  154.      Resume MakeDynaset
  155.    End If
  156.    ShowError
  157.    Resume SQLEnd
  158.  
  159. SQLDSErr:
  160.    Resume SQLEnd
  161.  
  162. SQLEnd:
  163.    ResetMouse Me
  164.    MsgBar "", False
  165.  
  166. End Sub
  167.  
  168. Sub Form_Load ()
  169.   Dim x As Integer
  170.  
  171.   cSQLStatement = GetINIString("SQLStatement", "")
  172.  
  173.   x = Val(GetINIString("SQLWindowHeight", "3000"))
  174.   Height = x
  175.   x = Val(GetINIString("SQLWindowWidth", "5370"))
  176.   Width = x
  177.   x = Val(GetINIString("SQLWindowTop", "0"))
  178.   Top = x
  179.   x = Val(GetINIString("SQLWindowLeft", CStr(fTables.Left + fTables.Width)))
  180.   Left = x
  181.  
  182. End Sub
  183.  
  184. Sub Form_Paint ()
  185.   Outlines Me
  186. End Sub
  187.  
  188. Sub Form_Resize ()
  189.   On Error Resume Next
  190.  
  191.   If WindowState <> 1 Then
  192.     cSQLStatement.Width = Width - 320
  193.     cSQLStatement.Height = Height - 1450
  194.     Outlines Me
  195.     Me.Refresh
  196.   End If
  197. End Sub
  198.  
  199. Sub Form_Unload (Cancel As Integer)
  200.   Dim x As Integer
  201.  
  202.   Me.WindowState = 1
  203.   Cancel = True
  204. End Sub
  205.  
  206.