I'm developing a web part (in VS 2010 for SharePoint 2010) to seach all content in a Publishing Site Collection. I have the following code (just testing before I change the scope and the select fields) :
FullTextSqlQuery q = new FullTextSqlQuery(SPContext.Current.Site);
q.QueryText = "SELECT ContentType FROM SCOPE() WHERE \"scope\"='All Sites'";
q.ResultTypes = ResultTypes.RelevantResults;
ResultTableCollection qr = q.Execute();
When (in debug) it gets to the last line I get the following error :
"ScopeNotFoundException was handled by user code"
"Scope in your query does not exist"
I have also tried this on a team site and get the same error. If I remove the scope condition ("SELECT ContentType FROM SCOPE()") I get results returned. Obviously the 'All Sites' scope is shared (I tried this after a custom scope didn't work). The search on the publishing site works as normal.
I have also made sure that my scopes are shared (tried with some custom scopes to no avail).
Any help would be greatly appreciated.