标题:还是搜索问题
只看楼主
zgjxl
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2006-11-14
 问题点数:0 回复次数:1 
还是搜索问题
this.Stxt=Request.Params["Stxt"].ToString();//这是页面传过来要查询的文本
this.Threadid=Convert.ToInt32(Request.Params["typeid"]);//传过来的类型编号(在哪个论坛类型查)

OleDbConnection conn=new OleDbConnection(ConfigurationSettings.AppSettings["connectionString"]);
OleDbCommand cmd=new OleDbCommand("select * from Threads where typeid=@Threadid and subject Like '%@subject%'",conn);
cmd.Parameters.Add(new OleDbParameter("@Threadid",OleDbType.UnsignedInt));
cmd.Parameters["@Threadid"].Value=Threadid;
cmd.Parameters.Add(new OleDbParameter("@subject",OleDbType.LongVarChar));
cmd.Parameters["@subject"].Value=Stxt;
OleDbDataAdapter adp=new OleDbDataAdapter(cmd);
DataSet ds=new DataSet();
adp.Fill(ds,"Threads");
this.DataGrid1.DataSource=ds.Tables["Threads"].DefaultView;
this.DataGrid1.DataBind();
问题>输入要查询的文本,DataGrid1一条纪录也不显示,可在数据库里明明有.
搜索更多相关主题的帖子: subject 搜索 target OleDbCommand 
2006-12-20 16:10
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
得分:0 

this.Stxt = Request.Params["Stxt"].ToString();//这是页面传过来要查询的文本
this.Threadid = Convert.ToInt32(Request.Params["typeid"]);//传过来的类型编号(在哪个论坛类型查)

string sqlstr = "select * from Threads where typeid=" + Threadid + " and subject Like '%" + Stxt + "%'"
OleDbConnection conn = new OleDbConnection(ConfigurationSettings.AppSettings["connectionString"]);
OleDbDataAdapter adp = new OleDbDataAdapter(sqlstr,conn);
DataSet ds = new DataSet();
adp.Fill(ds);
this.DataGrid1.DataSource=ds.Tables[0].DefaultView;
this.DataGrid1.DataBind();

你这样试试.


飘过~~
2006-12-20 19:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-110839-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.085861 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved