我有非常奇怪的問題,我不知道如何擺脫這一點。高級搜索 - 網址編碼
我有我的項目,它基本上學校搜索
ACC我的問題是我使用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);
KHYATI而不是請你能告訴我如何或你在哪裏得到的查詢 – HatSoft 2012-07-26 21:46:28
你是不是從URL傳遞這些參數正確的是你嗎?你是如何建立和執行這些查詢的?一些額外的代碼會非常有幫助 - 顯示如何將查詢放在一起並在數據庫上運行它會很好。請注意,如果您從URL直接傳遞參數,那麼存在SQL注入的嚴重風險。 – dash 2012-07-26 21:47:22
你嘗試過什麼嗎?像URLDecode()? 正如前面提到的,通過URL傳遞完整的查詢或查詢參數並不是一個好主意。 – 2012-07-26 21:49:49