连字符/短划线打破搜索
问题描述:
当名称包含连字符时,它无法获取正确的行。 它实际上没有任何获取连字符/短划线打破搜索
XAML:
<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 ";
}
答
您正在清理WhereParameters
,但在第二个使用参数@Name
where子句。我想你不应该清除WhereParameters
。
好吧我删除了清除...但我仍然有同样的问题。搜索仅在连字符“ - ”时才起作用 – rtp 2012-08-13 10:06:38
然后尝试使用SQL Server Profiler捕获正在执行的SQL。这很容易。请完整发布SQL。 – usr 2012-08-13 10:34:51
我得到它的工作,谢谢你 – rtp 2012-08-13 10:57:43