我在asp.net中搜索時遇到問題,當我嘗試在sqlserver中運行代碼或使用查詢buider時,它工作正常。但是當我在瀏覽器中運行程序時,gridview甚至沒有顯示出來。幫助PLZ。sqldatasource選擇命令沒有工作
protected void btnsearchadvance_Click(object sender, EventArgs e)
{
if (txtname.Text.Trim() != "")
{
search = "NmBengkel LIKE '%" + txtname.Text + "%'";
}
if (txtaddress.Text.Trim() != "")
{
search = search + " AND Address LIKE '%" + txtaddress.Text + "%'";
}
if (txttelp.Text.Trim() != "")
{
search = search + " AND NoTelp LIKE '%" + txttelp.Text + "%'";
}
if (txtnote.Text.Trim() != "")
{
search = search + " AND Note LIKE '%" + txtnote.Text + "%'";
}
SqlDataSource1.SelectCommand = "SELECT * FROM mst_bengkel where " + search;
}
你可以給我完整的代碼放在哪裏的參數化查詢?我應該在sqlserver上做這個過程嗎? – Lia
是的,你必須做出過程的例子:'prc_GetSampleData' – Shankaranand
好嗎和參數化查詢? visual studio中的代碼如何? – Lia