Set rs = CreateObject("ADODB.Recordset")
Set conn = CreateObject("ADODB.Connection")
With conn
.Provider = "SQLOLEDB"
.Mode = adModeReadWrite
.ConnectionString = "Data Source = (local); Initial Catalog = xxx; User Id = xxx; Password=xxx"
.Open
End With
strSQLQuery = "SELECT COUNT(*) AS MyRecordCount FROM [tableName]"
rs.Open strSQLQuery, conn
If Not rs.EOF Then
rs.MoveFirst
Do While Not rs.EOF
WScript.Echo(rs("MyRecordCount"))
rs.movenext
loop
End If
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing |