home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / sql / sqldmo / vb / generic / generic.frm (.txt) next >
Encoding:
Visual Basic Form  |  1996-04-03  |  4.0 KB  |  137 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMain 
  3.    Caption         =   "SQL-DMO Generic"
  4.    ClientHeight    =   6015
  5.    ClientLeft      =   510
  6.    ClientTop       =   675
  7.    ClientWidth     =   6735
  8.    BeginProperty Font 
  9.       name            =   "MS Sans Serif"
  10.       charset         =   1
  11.       weight          =   700
  12.       size            =   8.25
  13.       underline       =   0   'False
  14.       italic          =   0   'False
  15.       strikethrough   =   0   'False
  16.    EndProperty
  17.    Height          =   6420
  18.    Left            =   450
  19.    LinkTopic       =   "Form1"
  20.    ScaleHeight     =   6015
  21.    ScaleWidth      =   6735
  22.    Top             =   330
  23.    Width           =   6855
  24.    Begin VB.TextBox txtOut 
  25.       Height          =   4695
  26.       Left            =   120
  27.       MultiLine       =   -1  'True
  28.       ScrollBars      =   3  'Both
  29.       TabIndex        =   5
  30.       Top             =   1200
  31.       Width           =   6495
  32.    End
  33.    Begin VB.CommandButton cmdExit 
  34.       Caption         =   "E&xit"
  35.       Height          =   375
  36.       Left            =   5640
  37.       TabIndex        =   4
  38.       Top             =   120
  39.       Width           =   975
  40.    End
  41.    Begin VB.CommandButton cmdConnect 
  42.       Caption         =   "&Connect"
  43.       Height          =   375
  44.       Left            =   4560
  45.       TabIndex        =   3
  46.       Top             =   120
  47.       Width           =   975
  48.    End
  49.    Begin VB.TextBox txtPassword 
  50.       Height          =   285
  51.       Left            =   1320
  52.       PasswordChar    =   "*"
  53.       TabIndex        =   2
  54.       Top             =   840
  55.       Width           =   2775
  56.    End
  57.    Begin VB.TextBox txtLogin 
  58.       Height          =   285
  59.       Left            =   1320
  60.       TabIndex        =   1
  61.       Top             =   480
  62.       Width           =   2775
  63.    End
  64.    Begin VB.TextBox txtServer 
  65.       Height          =   285
  66.       Left            =   1320
  67.       TabIndex        =   0
  68.       Top             =   120
  69.       Width           =   2775
  70.    End
  71.    Begin VB.Label lblPassword 
  72.       Caption         =   "Password:"
  73.       Height          =   255
  74.       Left            =   120
  75.       TabIndex        =   8
  76.       Top             =   840
  77.       Width           =   855
  78.    End
  79.    Begin VB.Label lblLogin 
  80.       Caption         =   "Login:"
  81.       Height          =   255
  82.       Left            =   120
  83.       TabIndex        =   7
  84.       Top             =   480
  85.       Width           =   615
  86.    End
  87.    Begin VB.Label lblServer 
  88.       Caption         =   "SQL Server:"
  89.       Height          =   255
  90.       Left            =   120
  91.       TabIndex        =   6
  92.       Top             =   120
  93.       Width           =   1095
  94.    End
  95. Attribute VB_Name = "frmMain"
  96. Attribute VB_Creatable = False
  97. Attribute VB_Exposed = False
  98. Option Explicit
  99. ' Global variables
  100. Dim oSQLServer As SQLOLE.SQLServer
  101. Dim NL As String
  102. Private Sub cmdConnect_Click()
  103.     On Error Resume Next
  104.     frmMain.MousePointer = 11
  105.     oSQLServer.DisConnect
  106.     oSQLServer.Connect txtServer.Text, txtLogin.Text, txtPassword.Text
  107.     With txtOut
  108.         If Err.Number = 0 Then
  109.             .Text = "Connected to SQL Server " & oSQLServer.TrueName & NL
  110.             Dim oProperty As Object
  111.             .Text = .Text & "Properties for " & oSQLServer.Name & NL
  112.             For Each oProperty In oSQLServer.Properties
  113.                 .Text = .Text & oProperty.Name & ": " & oProperty.Value & NL
  114.             Next
  115.         Else
  116.             .Text = Err.Source & " Error " & Err.Number - vbObjectError & ":" & NL
  117.             .Text = .Text & "    " & Err.Description
  118.         End If
  119.     End With
  120.     frmMain.MousePointer = 0
  121.         
  122. End Sub
  123. Private Sub cmdExit_Click()
  124.     Unload frmMain
  125. End Sub
  126. Private Sub Form_Load()
  127.     On Error Resume Next
  128.     NL = Chr$(13) & Chr$(10)
  129.     Set oSQLServer = New SQLOLE.SQLServer
  130.     oSQLServer.LoginTimeout = 10
  131. End Sub
  132. Private Sub Form_Unload(Cancel As Integer)
  133.     On Error Resume Next
  134.     oSQLServer.DisConnect
  135.     oSQLServer.Close
  136. End Sub
  137.