Write a VB Script to test connection to your sql server

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject(“ADODB.Connection”)
Set objRecordSet = CreateObject(“ADODB.Recordset”)

objConnection.Open _
“Provider=SQLOLEDB;Data Source=localhost;” & _
“Trusted_Connection=Yes;Initial Catalog=TestDB;” & _
“User ID=testUser;Password=password;”

objRecordSet.Open “SELECT * FROM Customers”, _
objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Wscript.Echo objRecordSet.RecordCount

Leave a Reply

Your email address will not be published. Required fields are marked *