高效搜索搜索按钮上的数据库记录。 [英] efficient searching records from database on search button.
本文介绍了高效搜索搜索按钮上的数据库记录。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用此代码来解决该问题,但它无法正常工作,然后提供正确的搜索解决方案。
i tried this code for solve that problem but it not working properly then give a right searching solution.
string s = Request.QueryString["serc"];
SqlDataAdapter ad = new SqlDataAdapter("SELECT product_tbl.pname, product_tbl.path, product_tbl.price, product_tbl.cat, product_detail.product_info FROM product_tbl INNER JOIN product_detail ON product_tbl.pro_id = product_detail.pro_id where product_tbl.pname like '%" + s + "%'", con);
DataSet ds = new DataSet();
con.Open();
ad.Fill(ds);
con.Close();
GridView1.DataSource = ds;
GridView1.DataBind();
推荐答案
首先,您需要检查在Request.QueryString [serc]中是否获得了正确的值。
其次,当您使用'%< searchstring>%'时,它将检索产品名称中包含'searchString'的所有项目。
例如,如果所有产品都包含'pro'(产品名称中的任何位置)&你的searchString也是'pro',它会返回所有项目。
First you need to check whether you are getting correct value in Request.QueryString["serc"].
Second, as you are using '%<searchstring>%', it would retrieve all the items which contain 'searchString' in the Product names.
For example, if all of the products contain 'pro'(anywhere in the product names) & your searchString is also 'pro', it'll return all the items.
这篇关于高效搜索搜索按钮上的数据库记录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文