I am using the Windows Search API from C# with the following query:
SELECT System.ItemNameDisplay,SYSTEM.ITEMURL,System.DateModified, System.ItemName, System.Search.Rank, System.Keywords, System.Search.AutoSummary,System.Search.GatherTime, System.ItemType FROM "SYSTEMINDEX" WHERE CONTAINS(*,'"cowie*"',1033) Order By System.DateModified Desc
This command is supplied to an OleDbCommand object, which is read in a loop:
while (reader.Read())
{...}
When the command runs, an unspecified error is produced at the Reader.Read() statement after processing the last result. If the search string does not exist in the Windows search index, the error is thrown with no results returned.
Whilst the error can be trapped by its "Unspecified Error" message and not presented to the user as an error (as all results seem to be returned before it occurs), it would be better to prevent it from occurring at all. Can anyone offer any guidance on how to do this?