Option Explicit
Dim RS As ADODB.Recordset
Private Sub DoQuery(HTTPServer As String)
Dim Scope, QueryText, sSQL As String
Scope = "C:\" ' Set the scope of the query
QueryText = "Index" ' Set the criteria of the query
sSQL = "SELECT Filename, Path, Size, Write FROM Scope('" + Chr(34) + _
Scope + Chr(34) + "') WHERE CONTAINS('" + Chr(34) + QueryText + _
Chr(34) + "') > 0" ' ORDER BY Rank DESC"
' Create the recordset via the data-factory
Data_Factory HTTPServer, sSQL
' Print out column titles
Debug.Print "Filename", "Path", "Size", "Write"
Debug.Print "-------------", "------", "------", "----------"
' Print out data
Do Until RS.EOF
Debug.Print RS("Filename"), RS("Path"), RS("Size"), RS("Write")
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
End Sub
Private Sub Command1_Click()
Dim HTTPServer As String
Dim WebServer As String
WebServer = InputBox("What is the name of your Web (IIS) Server?")
HTTPServer = WebServer
' Execute the query
DoQuery (HTTPServer)
End Sub
Public Sub Data_Factory(HTTPServer As String, sSQL As String)
Dim DS As New RDS.DataSpace
Dim DF As Object
Set DF = DS.CreateObject("RDSServer.DataFactory", "http://" & HTTPServer)
'next line produces error (not recognizing the provider) with NT4 SP3 or before
Set RS = DF.Query("Provider=msidxs", sSQL, adOpenDynamic)
End Sub