gpt4 book ai didi

C#:SQL FilterExpression - 缺少操作数异常

转载 作者:行者123 更新时间:2023-12-03 03:11:28 24 4
gpt4 key购买 nike

我正在关注列出的可搜索gridview代码HERE 。我在使用 FilterExpression 时遇到问题。我得到了异常(exception):

Missing operand after 'Name' operator... When the exception occurs, FilterExpression = " WHERE Name like 'spencer%'"

异常发生在以下代码中:

protected void BindSGVData()
{
//hfSearchText has the search string returned from the grid.
if (hfSearchText.Value != "")
{
RidesSQL.FilterExpression = " WHERE " + hfSearchText.Value; //EXCEPTION HERE!
}
DataView dv = (DataView)RidesSQL.Select(new DataSourceSelectArguments());
//hfSort has the sort string returned from the grid.
if (hfSort.Value != "")
{
dv.Sort = hfSort.Value;
}

RideSGV.DataSource = dv;
try
{
RideSGV.DataBind();
}
catch (Exception exp)
{
//If databinding threw exception bcoz current page index is > than available page index
RideSGV.PageIndex = 0;
RideSGV.DataBind();
}
finally
{
//Select the first row returned
if (RideSGV.Rows.Count > 0)
RideSGV.SelectedIndex = 0;
}
}

有什么想法吗?

最佳答案

RidesSQL.FilterExpression = " WHERE " + hfSearchText.Value; //EXCEPTION HERE!

应该是:

RidesSQL.FilterExpression = hfSearchText.Value; // NO EXCEPTION HERE!

关于C#:SQL FilterExpression - 缺少操作数异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9122526/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com