Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i am having a big problem here. i am trying to create a custom search field that only returns users. i am using FullTextSqlQuery to get my result. when i query for All Sites i get some results, but when i query for People i get nothing.

i have a 2 LONG weeks trying to make this work maybe you guys can tell me where i am going wrong.

also

i would like to display each result right now i only get 1 as you can see from my code.

how can i use a foreach method on my result.

THANKS IN ADVANCE!

void ExecuteStaffSearch(string Name)
    {
        SPSecurity.RunWithElevatedPrivileges(delegate()
        {
            string strUrl = "siteURL";

            using (SPSite site = new SPSite(strUrl))
            {
                using (FullTextSqlQuery query = new FullTextSqlQuery(site))
                {
                    string queryText = "SELECT PreferredName
                                        FROM scope() 
                                        WHERE CONTAINS(" + Name + ") AND 
                                        \"Scope\"='People' ORDER BY Title ASC";

                    query.QueryText = queryText.ToString();
                    query.ResultTypes = ResultType.RelevantResults;
                    query.RowLimit = 10;

                    ResultTableCollection results = query.Execute();

                    ResultTable queryResultsTable = results[ResultType.RelevantResults];
                    DataTable queryDataTable = new DataTable();
                    queryDataTable.Load(queryResultsTable, LoadOption.OverwriteChanges);

                    if (queryDataTable.Rows.Count > 0)
                    {
                        var rowCount = queryDataTable.Rows.Count;
                        Response.Write(rowCount + "</br>");
                    }                    
                }
            }
        });  
    }

protected void Page_Load(object sender, EventArgs e)
    {
        ExecuteStaffSearch("Name");             
    }
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.