【发布时间】:2014-12-26 15:48:04
【问题描述】:
我有一个带有 AutoCompelte Extender 的文本框,自动完成文本来自数据库。
我为自动完成列表编写了一个存储过程(其中我使用 crossJoin 绑定了来自两个不同表的两列)。
我的问题是:
当我从自动完成文本框中选择一个值并单击搜索按钮时,按钮后面的我的选择查询没有获取任何值。
我的代码是:
SqlConnection Con = new SqlConnection("DataSource=Localhost;User ID = sa; Password =xxxxx;Initial Catalog =sample;");
SqlCommand cmd = new SqlCommand("Select * from tblCategoryDetails where CategoryName LIKE '"+ TextSearch.Text"' ", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
GridView3.DataSource = dt;
GridView3.DataBind();
谁能帮我解决这个问题
【问题讨论】:
-
把
+放在sql查询最后'" + TextSearch.Text+"' -
Select * from tblCategoryDetails where CategoryName LIKE '%"+ TextSearch.Text + "%' ,这也不行,我的文本框有两个词要搜索
标签: c# asp.net autocomplete