'Finds items based on CONTAINS, FREETEXT, FORMS, or LIKE predicate
'This example uses FREETEXT to find reports with names of cities
'Passes search result recordset to DoResults (see Enumerating Results)
'get computer and domain information
Set info = CreateObject("ADSystemInfo")
Set infoNT = CreateObject("WinNTSystemInfo")
cName = infoNT.ComputerName
dName = info.DomainDNSName
'create connection object
Set Conn = CreateObject("ADODB.Connection")
Conn.Provider = "Exoledb.DataSource"
'URL for connection object
'is at the virtual directory root
cURL = "http://" & _
cName & "." & _
dName & "/" & _
"public"
Conn.Open cURL
'relative URL is the folder to search
relURL = "Reports/FieldOffices"
'search specification variable
searchspec = "Tokyo London Bogata Honolulu Cairo Sydney Chicago"
'predicate to use in search
predicate = "FREETEXT"
'Construct a query based on the search predicate.
Select Case predicate
Case "CONTAINS"
strQ = strQ & "WHERE CONTAINS(*, '" & Chr(34) & searchspec & Chr(34) & "') "
Case "FREETEXT"
strQ = strQ & "WHERE FREETEXT(*, '" & Chr(34) & searchspec & Chr(34) & "') "
Case "LIKE"
strQ = strQ & "WHERE ""urn:schemas:httpmail:textdescription"" LIKE '" & searchspec & "'"
Case "FORMSOF"
strQ = strQ & "WHERE CONTAINS('FORMSOF(INFLECTIONAL," & Chr(34) & searchspec & Chr(34) & ")')"
Case Else
strQ = strQ & "WHERE CONTAINS(*, '" & Chr(34) & searchspec & Chr(34) & "') "
End Select
Rs.Open strQ, Conn
'If empty recordset, return error
'If successful call DoResults routine passing the recorset
If Rs.EOF = True Then
On Error Resume Next
Err.Raise adErrNoCurrentRecord
Response.Write "No items found, run another query."
Else
Response.Write "Success! Found " & Rs.RecordCount
DoResults Rs
End If
Rs.Close