Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将此筛选器表达式更改为参数化查询?_C#_Javascript_Asp.net_Webforms - Fatal编程技术网

C# 如何将此筛选器表达式更改为参数化查询?

C# 如何将此筛选器表达式更改为参数化查询?,c#,javascript,asp.net,webforms,C#,Javascript,Asp.net,Webforms,大家早上好, 如何将此筛选器表达式转换为参数化查询,但仍显示在gridview中?现在,如果我搜索%^&%*它会崩溃 C#: ASP: 管理赢家- | 错误: Like运算符中出错:字符串模式“@#%$%”无效 描述:在执行过程中发生未处理的异常 当前的web请求。请查看堆栈跟踪以了解更多信息 有关错误的信息及其在代码中的来源 异常详细信息:System.Data.EvaluateException:Like中出错 运算符:字符串模式“%@#%$%”无效 源错误: 在执行过程中生成了未处

大家早上好, 如何将此筛选器表达式转换为参数化查询,但仍显示在gridview中?现在,如果我搜索%^&%*它会崩溃

C#:

ASP:


管理赢家-
| 

错误:

Like运算符中出错:字符串模式“@#%$%”无效

描述:在执行过程中发生未处理的异常 当前的web请求。请查看堆栈跟踪以了解更多信息 有关错误的信息及其在代码中的来源

异常详细信息:System.Data.EvaluateException:Like中出错 运算符:字符串模式“%@#%$%”无效

源错误:

在执行过程中生成了未处理的异常 当前web请求。关于货物来源和位置的信息 可以使用下面的异常堆栈跟踪来识别异常

堆栈跟踪:

[EvaluateException:Like运算符中的错误:字符串模式 “%@#%$%”无效。]System.Data.LIKEODE.AnalyzePattern(字符串 pat)+1251846 System.Data.likeode.Eval(数据行,数据行版本 version)+345系统.Data.BinaryNode.EvalBinaryOp(Int32 op, ExpressionNode左侧、ExpressionNode右侧、DataRow行、DataRowVersion 版本,Int32[]记录编号)+13013
System.Data.BinaryNode.Eval(数据行,数据行版本)+29
System.Data.BinaryNode.EvalBinaryOp(Int32操作,ExpressionNode左, ExpressionNode right,DataRow行,DataRowVersion版本,Int32[] recordNos)+13013 System.Data.BinaryNode.Eval(DataRow行, 数据行版本)+29
System.Data.BinaryNode.EvalBinaryOp(Int32操作,ExpressionNode左, ExpressionNode right,DataRow行,DataRowVersion版本,Int32[] recordNos)+13013 System.Data.BinaryNode.Eval(DataRow行, 数据行版本)+29
System.Data.BinaryNode.EvalBinaryOp(Int32操作,ExpressionNode左, ExpressionNode right,DataRow行,DataRowVersion版本,Int32[] recordNos)+13013 System.Data.BinaryNode.Eval(DataRow行, 数据行版本)+29
System.Data.BinaryNode.EvalBinaryOp(Int32操作,ExpressionNode左, ExpressionNode right,DataRow行,DataRowVersion版本,Int32[] recordNos)+13013 System.Data.BinaryNode.Eval(DataRow行, 数据行版本)+29
System.Data.DataExpression.Invoke(DataRow行,DataRowVersion版本) +151 System.Data.Index.AcceptRecord(Int32记录,IFilter筛选器)+103 System.Data.Index.InitRecords(IFilter筛选器)+303 System.Data.Index..ctor(数据表,Int32[]ndexDesc, IndexField[]indexFields,比较'1比较,DataViewRowState 记录状态,IFilter rowFilter)+491
System.Data.DataTable.GetIndex(IndexField[]indexDesc, DataViewRowState记录状态,IFilter rowFilter)+228
System.Data.DataView.UpdateIndex(布尔力,布尔fireEvent) +165 System.Data.DataView.UpdateIndex(布尔力)+12 System.Data.DataView.SetIndex2(字符串newSort,DataViewRowState NewRowState,IFilter newRowFilter,布尔fireEvent)+113
System.Data.DataView.SetIndex(字符串newSort,DataViewRowState 新行状态,IFilter newRowFilter)+17
System.Data.DataView.set_RowFilter(字符串值)+160
System.Web.UI.WebControl.FilteredataSetHelper.CreateFilteredDataView(数据表 表,字符串排序表达式,字符串筛选器表达式,IDictionary 过滤器参数)+396
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments 参数)+2012
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments) 参数,DataSourceViewSelectCallback)+21
System.Web.UI.WebControls.DataBoundControl.PerformSelect()+143
System.Web.UI.WebControls.BaseDataBoundControl.DataBind()+74
System.Web.UI.WebControls.GridView.DataBind()+4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()+66
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75 System.Web.UI.Control.EnsureChildControl()+102 System.Web.UI.Control.PreRenderRecursiveInternal()+42
System.Web.UI.Control.PreRenderRecursiveInternal()+175
System.Web.UI.Control.PreRenderRecursiveInternal()+175
System.Web.UI.Control.PreRenderRecursiveInternal()+175
System.Web.UI.Control.PreRenderRecursiveInternal()+175
System.Web.UI.Control.PreRenderRecursiveInternal()+175
System.Web.UI.Page.ProcessRequestMain(布尔值 IncludeStages前同步点,布尔值IncludeStages后同步点) +2496

真诚地,
Christopher Witalis Peterson

您尝试过将搜索文本参数化为“%”+@searchText++“%”吗?

SelectCommand=“选择[PlayerID]、[昵称]、[UserName]、[ClubNumber]、[FirstName]、[Email]、[LastName]、[DOB]来自[Players],其中昵称如“%”+@昵称+“%”按姓氏排序ASC>
 SelectCommand="SELECT [PlayerID], [Nickname], [UserName], [ClubNumber], [FirstName], [Email], [LastName], [DOB] FROM [Players] where Nickname like '%'+@Nickname+'%' order by lastname ASC">
                <SelectParameters>
                     <asp:ControlParameter ControlID="txtWinnersSearch" Name="Nickname" PropertyName="Text" Type="String"/>
                </SelectParameters>
            </asp:SqlDataSource>

早上好,我很抱歉,没有。你会建议我怎么做呢?谢谢你迄今为止的帮助。诚恳地说,Christopher Witalis PetersonSelectCommand=“选择[PlayerID],[N
<asp:Panel ID="pnlWinners" DefaultButton="BtnWinnersSearch" runat="server" Visible="False">
        <table>
        <tr>
            <td align="center"><b>MANAGE WINNERS</b> - 
            <asp:Button ID="BtnWinnerAdd" runat="server" Text="Add" 
                    onclick="BtnWinnerAdd_Click" /> | 
                <asp:TextBox ID="txtWinnersSearch" runat="server" MaxLength="220"></asp:TextBox>
                    <asp:Button ID="BtnWinnersSearch"
                    runat="server" Text="Search" onclick="BtnWinnersSearch_Click"  />
            </td>
        </tr>
        <tr>
        <td>
                <asp:GridView ID="GridViewWinners" runat="server" AutoGenerateColumns="False" DataKeyNames="PlayerID"
                DataSourceID="SqlDataSource4" 
                EmptyDataText="There are no winners to display." CellPadding="4"
                AllowSorting="True" 
                onsorting="GridViewWinners_Sorting" 
                ForeColor="#333333" 
                Visible="False"
                onselectedindexchanged="GridViewWinners_SelectedIndexChanged" 
                    FooterStyle-Wrap="False" HeaderStyle-Wrap="False" PagerStyle-Wrap="False" 
                    RowStyle-Wrap="False" SelectedRowStyle-Wrap="False" Font-Overline="False" >
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" HorizontalAlign="Center" 
                        VerticalAlign="Middle" Wrap="False" />
                <Columns>
                    <asp:CommandField ShowSelectButton="True"/>
                    <asp:BoundField DataField="PlayerID" HeaderText="PlayerID" InsertVisible="False" 
                        ReadOnly="True" SortExpression="PlayerID" Visible="False" />
                        <asp:BoundField DataField="Nickname" HeaderText="Nickname" 
                        SortExpression="Nickname" ItemStyle-Wrap="False">
                    <ItemStyle Wrap="False" />
                    </asp:BoundField>
                    <asp:BoundField DataField="LastName" HeaderText="Last Name" 
                        SortExpression="LastName" ItemStyle-Wrap="False">
                    <ItemStyle Wrap="False" />
                    </asp:BoundField>
                    <asp:BoundField DataField="FirstName" HeaderText="First Name" 
                        SortExpression="FirstName" />
                    <asp:BoundField DataField="UserName" HeaderText="UserName" 
                        SortExpression="UserName" />
                    <asp:BoundField DataField="ClubNumber" HeaderText="Account Number" 
                        SortExpression="ClubNumber" />
                    <asp:BoundField DataField="Email" HeaderText="Email" 
                        SortExpression="Email" />
                    <asp:BoundField DataField="DOB" HeaderText="D.O.B." 
                        DataFormatString="{0:d}" SortExpression="DOB" />
                </Columns>
                <EditRowStyle BackColor="#999999" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" 
                        HorizontalAlign="Center" VerticalAlign="Middle" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" 
                        HorizontalAlign="Center" VerticalAlign="Middle" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#E9E7E2" />
                <SortedAscendingHeaderStyle BackColor="#506C8C" />
                <SortedDescendingCellStyle BackColor="#FFFDF8" />
                <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
            </asp:GridView>
            </td>
            </tr>
            </table>
            </asp:Panel>
             <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
                ConnectionString="****" 
                ProviderName="***" 
                SelectCommand="SELECT [PlayerID], [Nickname], [UserName], [ClubNumber], [FirstName], [Email], [LastName], [DOB] FROM [Players] order by lastname ASC">
            </asp:SqlDataSource>
</asp:Content>
 SelectCommand="SELECT [PlayerID], [Nickname], [UserName], [ClubNumber], [FirstName], [Email], [LastName], [DOB] FROM [Players] where Nickname like '%'+@Nickname+'%' order by lastname ASC">
                <SelectParameters>
                     <asp:ControlParameter ControlID="txtWinnersSearch" Name="Nickname" PropertyName="Text" Type="String"/>
                </SelectParameters>
            </asp:SqlDataSource>