home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch11 / sqlexec / sqlform.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-20  |  4.9 KB  |  161 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  3. Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
  4. Begin VB.Form Form1 
  5.    Caption         =   "SQLEXE"
  6.    ClientHeight    =   5025
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   6795
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   5025
  12.    ScaleWidth      =   6795
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.CommandButton ExecuteSQL 
  15.       Caption         =   "Execute SQL"
  16.       Height          =   375
  17.       Left            =   5385
  18.       TabIndex        =   4
  19.       Top             =   1395
  20.       Width           =   1290
  21.    End
  22.    Begin VB.TextBox txtSQL 
  23.       Height          =   750
  24.       Left            =   135
  25.       MultiLine       =   -1  'True
  26.       ScrollBars      =   2  'Vertical
  27.       TabIndex        =   3
  28.       Top             =   975
  29.       Width           =   4620
  30.    End
  31.    Begin VB.Data Data1 
  32.       Caption         =   "Data1"
  33.       Connect         =   "Access"
  34.       DatabaseName    =   ""
  35.       DefaultCursorType=   0  'DefaultCursor
  36.       DefaultType     =   2  'UseODBC
  37.       Exclusive       =   0   'False
  38.       Height          =   345
  39.       Left            =   165
  40.       Options         =   0
  41.       ReadOnly        =   0   'False
  42.       RecordsetType   =   1  'Dynaset
  43.       RecordSource    =   ""
  44.       Top             =   4575
  45.       Visible         =   0   'False
  46.       Width           =   6630
  47.    End
  48.    Begin VB.CommandButton DBOpen 
  49.       Caption         =   "Open Database"
  50.       Height          =   375
  51.       Left            =   5385
  52.       TabIndex        =   2
  53.       Top             =   300
  54.       Width           =   1290
  55.    End
  56.    Begin MSDBGrid.DBGrid DBGrid1 
  57.       Bindings        =   "SQLForm.frx":0000
  58.       Height          =   2895
  59.       Left            =   135
  60.       OleObjectBlob   =   "SQLForm.frx":0010
  61.       TabIndex        =   1
  62.       Top             =   2175
  63.       Width           =   6585
  64.    End
  65.    Begin MSComDlg.CommonDialog CommonDialog1 
  66.       Left            =   6240
  67.       Top             =   930
  68.       _ExtentX        =   847
  69.       _ExtentY        =   847
  70.       _Version        =   327680
  71.       FontSize        =   1.17491e-38
  72.    End
  73.    Begin VB.Label Label4 
  74.       Caption         =   "Database Name"
  75.       BeginProperty Font 
  76.          Name            =   "MS Sans Serif"
  77.          Size            =   9.75
  78.          Charset         =   0
  79.          Weight          =   400
  80.          Underline       =   0   'False
  81.          Italic          =   0   'False
  82.          Strikethrough   =   0   'False
  83.       EndProperty
  84.       Height          =   225
  85.       Left            =   135
  86.       TabIndex        =   7
  87.       Top             =   75
  88.       Width           =   1725
  89.    End
  90.    Begin VB.Label Label3 
  91.       Caption         =   "SQL Statement"
  92.       BeginProperty Font 
  93.          Name            =   "MS Sans Serif"
  94.          Size            =   9.75
  95.          Charset         =   0
  96.          Weight          =   400
  97.          Underline       =   0   'False
  98.          Italic          =   0   'False
  99.          Strikethrough   =   0   'False
  100.       EndProperty
  101.       Height          =   240
  102.       Left            =   135
  103.       TabIndex        =   6
  104.       Top             =   720
  105.       Width           =   1680
  106.    End
  107.    Begin VB.Label Label2 
  108.       Caption         =   "Query Results"
  109.       BeginProperty Font 
  110.          Name            =   "MS Sans Serif"
  111.          Size            =   9.75
  112.          Charset         =   0
  113.          Weight          =   400
  114.          Underline       =   0   'False
  115.          Italic          =   0   'False
  116.          Strikethrough   =   0   'False
  117.       EndProperty
  118.       Height          =   240
  119.       Left            =   135
  120.       TabIndex        =   5
  121.       Top             =   1890
  122.       Width           =   1590
  123.    End
  124.    Begin VB.Label Label1 
  125.       BorderStyle     =   1  'Fixed Single
  126.       Height          =   255
  127.       Left            =   135
  128.       TabIndex        =   0
  129.       Top             =   360
  130.       Width           =   4605
  131.    End
  132. Attribute VB_Name = "Form1"
  133. Attribute VB_GlobalNameSpace = False
  134. Attribute VB_Creatable = False
  135. Attribute VB_PredeclaredId = True
  136. Attribute VB_Exposed = False
  137. Option Explicit
  138. Private Sub DBOpen_Click()
  139. On Error GoTo NoDatabase
  140. CommonDialog1.CancelError = True
  141. CommonDialog1.Filter = "Databases|*.MDB"
  142. CommonDialog1.ShowOpen
  143.     Data1.DatabaseName = CommonDialog1.filename
  144.     Data1.Refresh
  145.     If Err = 0 Then
  146.         Label1.Caption = CommonDialog1.filename
  147.     Else
  148.         MsgBox Err.Description
  149.     End If
  150. NoDatabase:
  151.     On Error GoTo 0
  152. End Sub
  153. Private Sub ExecuteSQL_Click()
  154. On Error GoTo SQLError
  155.     Data1.RecordSource = txtSQL
  156.     Data1.Refresh
  157.     Exit Sub
  158. SQLError:
  159.     MsgBox Err.Description
  160. End Sub
  161.