Nishand's Blog

Welcome to my personal blog, All the information in this bogs is my ideas,findings and thoughts on .Net, Asp.Net and SharePoint.
ALL POSTING ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND

FullTextSqlQuery with QueryText length greater than 4096 characters throws ArgumentOutOfRange exception.

The max number of characters that can be passed through FullTextSqlQuery is 4096 characters, beyond this length throws an exception ArgumentOutOfRangeException. You will get the same behavior when using the webservice QueryEx(XmlNode) as well.

   1: private void ExecQuery()
   2: {
   3: ResultTableCollection resultCollection = null;
   4: SPSite site = new SPSite("http://server/");
   5: FullTextSqlQuery fullText = new FullTextSqlQuery(site);
   6: fullText.ResultTypes = ResultType.RelevantResults;
   7: fullText.QueryText = "SELECT Title, Path, Description, Write, Rank, Size FROM Scope()"; //max 4096
   8: fullText.KeywordInclusion =KeywordInclusion.AnyKeyword;
   9: resultCollection = fullText.Execute();
  10: ResultTable results = resultCollection[ResultType.RelevantResults];
  11: dataGridView1.DataSource = null;
  12: if (results.RowCount > 0)
  13: {
  14: DataTable dtresults = new DataTable();
  15: dtresults.TableName = "Result"
  16: dtresults.Load(results, LoadOption.OverwriteChanges);
  17: DataSet ds = new DataSet("All_Results");
  18: ds.Tables.Add(dtresults);
  19: dataGridView1.DataSource = ds;
  20: dataGridView1.DataMember = "Result";
  21: }
  22: }

Hope this helps.

 

Published Thursday, October 02, 2008 12:30 PM by nishandv

Comments

 

FullTextSqlQuery with QueryText length >4096 throws ArgumentOutOfRange exception. : EasyCoded said:

October 2, 2008 3:42 PM
 

sridhara said:

Nice post - really helped me :)

October 2, 2008 4:11 PM
 

butaji said:

Hello!

1. Something u are forgot: if u using SPSite u must dispose this object.

Something like that.

using (SPSite site = new SPSite(...))

{

}

2. Did u fulltextsearch at SPList scope? pls answer me, if it possble. yafos(at)yandex(dot)ru

November 1, 2008 4:34 AM
 

Anjali's Blog said:

I was working on case, where Customer wanted to have the length of the QueryText property of FullTextSqlQuery

June 15, 2009 8:29 PM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker