C# 连字符/破折号打断搜索

C# 连字符/破折号打断搜索,c#,asp.net,sql,C#,Asp.net,Sql,如果名称包含连字符,则无法获取正确的行。 它实际上什么也没拿 XAml: 您正在清除WhereParameters,但在第二个where子句中使用parameter@Name。我想你不应该清除WhereParameters好的,我删除了清除。。。但我仍然有同样的问题。只有当出现连字符“-”时,搜索才会起作用。它不会提取行,然后尝试使用SQL Server Profiler捕获正在执行的SQL。这很容易。请完整发布SQL。 <asp:EntityDataSource ID="Enti

如果名称包含连字符,则无法获取正确的行。 它实际上什么也没拿

XAml:


您正在清除
WhereParameters
,但在第二个where子句中使用parameter
@Name
。我想你不应该清除
WhereParameters

好的,我删除了清除。。。但我仍然有同样的问题。只有当出现连字符“-”时,搜索才会起作用。它不会提取行,然后尝试使用SQL Server Profiler捕获正在执行的SQL。这很容易。请完整发布SQL。
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=Entities"
        DefaultContainerName="Entities" EnableFlattening="False" EntitySetName="CustomerClassifications">
    </asp:EntityDataSource>

        <div class="searchWrapper">
            Search
            <asp:Panel DefaultButton="btnSearch" runat="server" ID="pnlSearch">
            <asp:TextBox ID="tbxSearch" runat="server" CssClass="tbxSearch">
            </asp:TextBox>
            <asp:Button ID="btnSearch" runat="server" CssClass="btnSearch" Text="Search" />
            </asp:Panel>
        </div>
            this.EntityDataSource1.WhereParameters.Clear();
            if (string.IsNullOrEmpty(tbxSearch.Text))
            {
                this.EntityDataSource1.Where = "1 = 1";
            }
            else
            {
                this.EntityDataSource1.Where = "it.Name =  @Name ";
            }