我有一个非常奇怪的问题,我不知道如何解决这个问题。
我对我的项目有一个预先搜索,基本上是学校搜索
我的问题是我LIKE
用来比较选项,在搜索结束时,我的查询应该如下所示:
select *
from tbl_schooldetails
where
state = 'Gujarat'
and city = 'Ahmedabad'
and area = 'Navrangpura'
and ( board = 'xx' or board LIKE '%CBSE Board%' or board LIKE '%Gujarat Board%')
但相反,我得到以下查询:
select *
from tbl_schooldetails
where
state = 'Gujarat'
and city = 'Ahmedabad'
and area = 'Navrangpura'
and ( board = 'xx' or board LIKE '�SE Board%' or board LIKE '%Gujarat Board%')
如果您注意到我%CB
的已转换为“ �”符号,因此我无法搜索与“CBSE Board”选项相关的任何结果。
谁能告诉我如何摆脱这种 URL 编码?
这是我生成此查询的代码:
string qry = "select * from tbl_schooldetails where state = '" + sdpd4.SelectedItem.Text + "'";
if (sdpd2.SelectedItem.Text != "Select City")
{
qry += " and city = '" + sdpd2.SelectedItem.Text + "'";
}
if (sdpd1.SelectedItem.Text != "Select Area")
{
qry += " and area = '" + sdpd1.SelectedItem.Text + "'";
}
if (CheckBoxList3.SelectedItem != null)
{
qry = qry + " and ( board = 'xx'";
for (int i = CheckBoxList3.Items.Count - 1; i >= 0; i--)
{
if (CheckBoxList3.Items[i].Selected == true)
{
string mt = CheckBoxList3.Items[i].ToString();
qry = qry + " or board LIKE '" + '%' + mt + '%' + "'";
}
}
qry = qry + ")";
}
if (RadioButtonList1.SelectedItem != null)
{
qry += " and gender ='" + RadioButtonList1.SelectedItem.Text + "'";
}
Response.Redirect("schoolsearchresult2.aspx?search=" + qry);