I am using the following code to make a connection to a SQL database. The code works fine on 98% of the PCs that I've run it on. The problem is, on a couple of PCs, the DB connection is never made. I know this because I can query for something that I know exists and an empty recordset is returned.

How can I check to see if the DB connection fails. It currently does not return any errors and doesn't affect the rest of the script, it just doesn't make the connection.

code:
  $DSN="DRIVER=SQL Server;SERVER=myserver;UID=me;PWD=mypwd;DATABASE=mydb"
$Connection = CreateObject("ADODB.Connection")
$Command = CreateObject("ADODB.Command")
$Recordset = CreateObject("ADODB.Recordset")

$Connection.ConnectionString = $DSN
$Connection.Open()
$Command.ActiveConnection = $Connection
$Recordset.CursorType = 3
$Recordset.LockType = 3
$Recordset.ActiveCommand = $Command

$Command.CommandText = "SELECT name FROM tbl_things where animal = 'dog'"
$Recordset.Open($Command)
If $Recordset.RecordCount >= 1
If $Recordset.Fields("animal").Value > ""
$rc = "found an name"
Else
$rc = "no name found"
EndIf
$Recordset.Close()
Else
$rc = "no records found" ;empty recordset
EndIf
$Connection.Close()
$Connection = 0
$Recordset = 0
$Command = 0