如何实现站内搜索 如何实现像当当网那样的站内搜索??我做的是购书网站!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是查询,你写个方法,设置一个多表的模糊查询,Jion,或者只模糊查询你的图书表,就行! 糊弄糊弄你们老板的了 这种搜索规则定制比较麻烦如果是产品多,那么肯定要用到分词,不能查数据库,查索引。。比如用lucene如果产品不多,那么定制规则比如空格是and 等等这样,然后直接查库喽 Repository.TBRepository tbrep = Repository.TBRepository.GetInstance(); TB.TBInfoDataTable tbDT = tbrep.getTB(); //药敏号 string yaominId = this.textBoxymID.Text; //菌株来源 string laiyuan = this.comboBoxlaiyuan.SelectedItem.ToString(); //菌株代期 string daiqi = this.comboBoxTBdaiqi.SelectedItem.ToString(); //菌株保存培养基 string pyj = this.comboBox3pyji.SelectedItem.ToString(); //菌株冰箱编号 string fridgeID = this.fridgeID.Text; //菌株保存架编号 string jiaID = this.textBox5jiaID.Text; //菌株保存盒编号 string heID = this.textBox6heID.Text; //保存管数 string guanshu = this.numericUpDown1.Value.ToString (); //入库时间 DateTime dt = this.dateTimePickerruku.Value ; //入库人 string inPeople = this.Inpeople.SelectedItem.ToString(); //备注 string res = this.richTextBox1.Text; StringBuilder whereString = new StringBuilder(); whereString.Append("1 = 1"); if (yaominId != "") whereString.Append(" and YaominID='" + yaominId + "'"); if(laiyuan != "全部") whereString.Append( "and "+"TBcause='" + laiyuan + "'"); if (pyj != "全部") whereString.Append( "and "+"TBculture='"+pyj+"'"); if (daiqi != "全部") whereString.Append( "and "+" TBdaiqi='"+daiqi +"'"); if (fridgeID != "") whereString.Append( "and "+" TBfridge='"+fridgeID +"'"); if (jiaID != "") whereString.Append( "and "+" TBjiaID='"+jiaID +"'"); if (heID != "") whereString.Append( "and "+" TBheID='"+heID +"'"); if (guanshu != "") whereString.Append( "and "+" TBnumber='"+guanshu +"'"); //if (dt != null ) // whereString.Append( "and "+ " TBindate='"+dt+"' "); if (inPeople != "") whereString.Append(" and "+" TBinpeople='" + inPeople + "' "); if (res != "") whereString.Append(" and "+" TBres='" + res + "'"); DataRow[] dr = tbDT.Select (whereString.ToString ()); this.listView1.Items.Clear(); foreach (TB.TBInfoRow item in dr) { ListViewItem showItem = new ListViewItem(); showItem.Text = item.YaominID; showItem.SubItems.Add(item.TBcause.ToString()); showItem.SubItems.Add(item.TBdaiqi.ToString()); showItem.SubItems.Add(item.TBculture.ToString()); showItem.SubItems.Add(item.TBfridge.ToString ()); showItem.SubItems.Add(item.TBjiaID.ToString ()); showItem.SubItems.Add(item.TBheID.ToString ()); showItem.SubItems.Add(item.TBnumber.ToString()); showItem.SubItems.Add(item.TBindate.ToString()); showItem.SubItems.Add(item.TBinpeople); showItem.SubItems.Add(item.TBres); showItem.Tag = item; listView1.Items.Add(showItem); } 我是从内存表中查询出的数据显示在listview上 但愿对你有用 即private DataTabel GetData(string sname){ string str="select * from dtTest where sname like '%"+sname+"%'"; sqlDataAdapate da=new sqlDataAdapate(); DataTable dt=new DataTable(); da.Fill(dt); return dt;}用一页面显示该DataTable的内容即可! 用一个页面显示此DataTable的内容即可! 多参数的处理方法比如文本框2个,一个输UserName,一个输UserPassStringBuild sb = new StringBuild();if(!String.isnullorEmpty(txtUserName.Text)){ sb.Append(" and UserName ='").Append(txtUserName.Text).Append("'");}if(!String.isnullorEmpty(txtUserPass.Text)){ sb.Append(" and UserPass ='").Append(txtUserPass.Text).Append("'");}然后条件就是sb.toString() <p>This site has your answer, click Connect:<a href="http://www.christianlouboutinonstore.com"><strong>louboutins shoes</strong></a> </p> This site has your answer, click Connect:louboutins shoes 在线等... winfrom webBrowser 技术选型问题? 在winform中写入和读取 到 text中 如何让一个窗体的自定义属性在别的窗体引用时只读? 为什么取不到datagrid模版列中textbox的值!急 请问:如何在ms saql存储图像并显示,c#.net 现在创建对话框是怎么回事呢? VBNET转C#的问题 请教: 怎么读取网卡的物理地址 为什么我用DrawReversibleLine方法画的线,总有虚点不能擦除 C# winform 程序将.chm文件设置为嵌入式资源文件,现在要获取该文件,代码怎么写? c#设置TreeView控件默认选择某节点
TB.TBInfoDataTable tbDT = tbrep.getTB();
//药敏号
string yaominId = this.textBoxymID.Text;
//菌株来源
string laiyuan = this.comboBoxlaiyuan.SelectedItem.ToString();
//菌株代期
string daiqi = this.comboBoxTBdaiqi.SelectedItem.ToString();
//菌株保存培养基
string pyj = this.comboBox3pyji.SelectedItem.ToString();
//菌株冰箱编号
string fridgeID = this.fridgeID.Text;
//菌株保存架编号
string jiaID = this.textBox5jiaID.Text;
//菌株保存盒编号
string heID = this.textBox6heID.Text; //保存管数
string guanshu = this.numericUpDown1.Value.ToString (); //入库时间
DateTime dt = this.dateTimePickerruku.Value ;
//入库人
string inPeople = this.Inpeople.SelectedItem.ToString();
//备注
string res = this.richTextBox1.Text; StringBuilder whereString = new StringBuilder();
whereString.Append("1 = 1");
if (yaominId != "")
whereString.Append(" and YaominID='" + yaominId + "'"); if(laiyuan != "全部")
whereString.Append( "and "+"TBcause='" + laiyuan + "'"); if (pyj != "全部")
whereString.Append( "and "+"TBculture='"+pyj+"'"); if (daiqi != "全部")
whereString.Append( "and "+" TBdaiqi='"+daiqi +"'"); if (fridgeID != "")
whereString.Append( "and "+" TBfridge='"+fridgeID +"'"); if (jiaID != "")
whereString.Append( "and "+" TBjiaID='"+jiaID +"'"); if (heID != "")
whereString.Append( "and "+" TBheID='"+heID +"'"); if (guanshu != "")
whereString.Append( "and "+" TBnumber='"+guanshu +"'"); //if (dt != null )
// whereString.Append( "and "+ " TBindate='"+dt+"' "); if (inPeople != "")
whereString.Append(" and "+" TBinpeople='" + inPeople + "' ");
if (res != "")
whereString.Append(" and "+" TBres='" + res + "'"); DataRow[] dr = tbDT.Select (whereString.ToString ()); this.listView1.Items.Clear();
foreach (TB.TBInfoRow item in dr)
{
ListViewItem showItem = new ListViewItem();
showItem.Text = item.YaominID;
showItem.SubItems.Add(item.TBcause.ToString());
showItem.SubItems.Add(item.TBdaiqi.ToString());
showItem.SubItems.Add(item.TBculture.ToString());
showItem.SubItems.Add(item.TBfridge.ToString ());
showItem.SubItems.Add(item.TBjiaID.ToString ());
showItem.SubItems.Add(item.TBheID.ToString ());
showItem.SubItems.Add(item.TBnumber.ToString());
showItem.SubItems.Add(item.TBindate.ToString());
showItem.SubItems.Add(item.TBinpeople);
showItem.SubItems.Add(item.TBres);
showItem.Tag = item; listView1.Items.Add(showItem); }
我是从内存表中查询出的数据显示在listview上 但愿对你有用
{
string str="select * from dtTest where sname like '%"+sname+"%'";
sqlDataAdapate da=new sqlDataAdapate();
DataTable dt=new DataTable();
da.Fill(dt);
return dt;
}
用一页面显示该DataTable的内容即可!
用一个页面显示此DataTable的内容即可!
比如文本框2个,一个输UserName,一个输UserPass
StringBuild sb = new StringBuild();
if(!String.isnullorEmpty(txtUserName.Text))
{
sb.Append(" and UserName ='").Append(txtUserName.Text).Append("'");
}
if(!String.isnullorEmpty(txtUserPass.Text))
{
sb.Append(" and UserPass ='").Append(txtUserPass.Text).Append("'");
}
然后条件就是sb.toString()