VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   1455
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6060
   LinkTopic       =   "Form1"
   ScaleHeight     =   1455
   ScaleWidth      =   6060
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox txtConnected 
      Height          =   405
      Left            =   360
      TabIndex        =   0
      Text            =   "Not Connected"
      Top             =   540
      Width           =   4635
   End
   Begin VB.Timer timTimer 
      Left            =   1650
      Top             =   120
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim objCnn As New ADODB.Connection

Private Sub Form_Load()

timTimer.Enabled = True
timTimer.Interval = 2000
    
End Sub

Sub ConnectSQL()
On Error Resume Next
If objCnn.State = 1 Then ' If Connection Is Open Then Close It Just for Testing Purposes
    objCnn.Close
End If

objCnn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=NORTHWIND;Data Source=MHARROLD"
objCnn.ConnectionTimeout = 1
objCnn.Open cnn
    
    
        Do While objCnn.State = adStateConnecting
            DoEvents
        Loop

    
If Err.Number <> 0 Then
    txtConnected.Text = "No Connection Found"
    
Else
    txtConnected.Text = "Connected To SQL Server"
End If

End Sub

Private Sub Form_Unload(Cancel As Integer)
If objCnn.State = 1 Then ' If Connection Is Open Then Close It
    objCnn.Close
End If

Set objCnn = Nothing
End Sub

Private Sub timTimer_Timer()
Call ConnectSQL
End Sub
