SearchExpression problem

6/27/2012 6:31:23 AM
Total Posts 2

SearchExpression problem

I am using searchexpression on shape file which contains over 30,000 points. Its works fine if expression contains few search items. However it return no record if number of search items exceed 4000 or so.

string expr = "LIKE(" + field + ", \"" + txtSearch + "\") OR LIKE(" + field + ", \"" + txtSearch1 + "\") ";
AspMap.Recordset rs = map[layerName].SearchExpression(expr)

Here expression contains only 2 searchable items where as it returns zero record if they exceed 4000 or 5000 items. Any solution to this problem or is their any alternate

 

Regards

Sheraz

6/27/2012 10:16:20 AM
MVP
Total Posts 323

Re: SearchExpression problem

Do you mean that it does not work if 4000  LIKE(FIELD, "value")  items is added?

6/28/2012 12:17:03 AM
Total Posts 2

Re: SearchExpression problem

Correction

Yes it looks

Initially SearchExpression function call was showing invalid expression exception. But without any change now it just return zero record. It display following information in the properties of recordset objectCount=-1

Extent = 'rs.Extent' threw an exception of type 'System.ArgumentException' (Internal Message: Recordset does not contain records)

FeatureID='rs.FeatureID' threw an exception of type 'System.ArgumentException'

Shape ='rs.Shape' threw an exception of type 'System.ArgumentException"

6/28/2012 5:52:58 AM
MVP
Total Posts 323

Re: SearchExpression problem

Please contact technical support and attach a fully working application to check this issue.


You may use the standard ParcelMap sample to check that there are no problems with the number of expression items if the expression is correct. Change the searchParcel_Click method as follows:

    protected void searchParcel_Click(object sender, System.EventArgs e)
    {
            string expr = "LIKE(PARNUM, \"" + parcelTextBox.Text.Trim() + "\")";

            string items = "";
                
            for (int i = 0; i < 5000; i++)
            {
                items += expr + " OR ";
            }

            items += expr;

        AspMap.Recordset rs = map["parcels"].SearchExpression(items);

        if (rs.EOF)
        {
            Response.Write("<font color=#FF0000>Parcel number not found.</font>");
            return;
        }

        map.Callouts.Clear();

        identifyGrid.DataSource = rs;
        identifyGrid.DataBind();
        identifyGrid.Caption = rs.Layer.Name.ToUpper();

        Callout callout = map.Callouts.Add();
        AspMap.Point center = rs.Shape.Centroid;
        callout.X = center.X;
        callout.Y = center.Y;
        callout.Text = rs["PARNUM"] + "\n" + rs["OWNERNAME"];
        callout.Font.Size = 16;

        map.Extent = rs.RecordExtent;
    }