小弟在做一个简单的模糊查询的时候遇到了如下问题:
我根据用户输入的两个值为参数,在数据库里搜索数据,然后把搜索出的数据绑定到DataGrid上。但DataGrid把一张表的所有记录都显示出来了。这样的结果不是我想要的。
我的SQL语句在查询分析器里执行无任何问题,能根据条件正确显示出一条或多条记录;代码如下,望各位朋友多多指教。public string temp_uid,temp_email;temp_uid = Request.QueryString["kwu"];
temp_email = Request.QueryString["kwe"];con.Open();
SqlDataAdapter sqlada = new SqlDataAdapter("select uid,name,email from associator where uid like '%"+temp_uid+"%' and email like '%+temp_email+%'",con);
DataSet ds = new DataSet();
sqlada.Fill(ds,AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1),AspNetPager1.PageSize,"temptable");
DataGrid1.DataSource = ds.Tables["temptable"];
DataGrid1.DataBind();
con.Close();