Enumerating Search Results
Enumerating Search Results
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
This example shows how to process a returned recordset, accommodating for multivalued and null properties, and how to render the results.
VBScript
'writes property values from a recordset (Rs) 'returned from a SQL query 'The DoResults function writes an HTML table 'for each record (item) in the recordset. In that table 'each property and value are written to a table cell, 'accommodating for null and multivalued properties. On Error GoTo Function DoResults(Rs) 'If empty recordset, return error If Rs.EOF = True Then On Error Resume Next Err.Raise adErrNoCurrentRecord Response.Write "<br><FONT FACE=Arial SIZE=2>No items found, run another query.<p>" Else Rs.MoveFirst Do Until Rs.EOF 'Create a HTML table for each record, make table headings stand out Response.Write "<FONT FACE=Arial SIZE=2><TABLE BORDER=1 cellpadding=5 cellspacing=5>" Response.Write "<TR><TH bgcolor=#0000ff><FONT color=#ffffff>Property</TH>" Response.Write "<TH bgcolor=#0000ff><FONT color=#ffffff>Value</TH></TR>" For Each f In Rs.Fields 'for every field in the record Response.Write "<TR><TD><FONT SIZE=1>" Response.Write f.Name Response.Write "</TD><TD><FONT SIZE=1>" 'accommodate null and multivalued properties If Not IsNull(f.Value) Then If IsArray(f.Value) Then 'a multivalued property Dim V For Each V In f.Value On Error Resume Next Response.Write(V & "<br>") Next Else On Error Resume Next Response.Write f.Value End If Else 'Field is null Response.Write "Null" End If Response.Write "</TD></TR>" Next Response.Write "</TABLE><br><hr><br>" Rs.MoveNext Loop End If End Function GoTo Ending ' Implement custom error handling here. ErrHandler: MsbBox Err.Number + " " + Err.Description Err.Clear Ending:
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.