CodeSmith Community
Your Code. Your Way. Faster!

LIKE Search with spaces

Latest post 05-02-2008 2:27 AM by swin. 1 replies.
  • 05-01-2008 3:32 PM

    • CitizenBane
    • Top 50 Contributor
    • Joined on 10-30-2007
    • Grand Rapids, MI
    • Posts 94
    • Points 1,740

    LIKE Search with spaces

    I created a simple search form with a gridview result.

    The DataSource control markup looks like this:

    <data:AirportCodeDataSource ID="AirportCodeDataSource1" runat="server" SelectMethod="GetPaged" EnablePaging="true" EnableSorting="true">
        <Parameters>
            <data:SqlParameter Name="WhereClause" UseParameterizedFilters="false">
                <Filters>
                    <data:AirportCodeFilter Column="CountryCode" ControlID="ddlCountryList" />
                    <data:AirportCodeFilter Column="City" ControlID="txtSearch" ComparisionType="Like" />
                </Filters>
            </data:SqlParameter>
        </Parameters>
    </data:AirportCodeDataSource>

    When I attempt to do a search, no matter what I type in to my txtSearch, I always end up with an empty result.

    If I change ComparisionType (Which is spelled incorrectly, by the way (hint: It's Comparison)) to "Contains", I am able to perform a search.

    If I type in "Grand", I end up with the appropriate results.  However, if I type in "Grand Rapids", my query does not find the record it is supposed to, even though I know it is there.

    Is this because "Grand Rapids" gets encoded or something along the way?  Does anyone know how I can get around this issue?

    Thanks.

    Edit: Ok, I see that if I use the ComparisonType of "Like", If I enter the wildcards % in to my text box, the search performs as it should.  I still don't understand the spacing issue.

    Edit 2: I have also found that several of the read-only properties of SqlParameter.cs are commented that they are writable.

    I'm outside ur box, shiftin' ur paradigm.
    • Post Points: 35
  • 05-02-2008 2:27 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 922
    • Points 34,710

    Re: LIKE Search with spaces

    CB, 

    With regards to your Contains search see http://community.codesmithtools.com/forums/p/5677/22596.aspx#22596

    hth

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 5
Page 1 of 1 (2 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems