php 搜索字符串,字符串搜索的问题

字符串搜索的问题 - 故障解答 - 电脑教程网

字符串搜索的问题

日期:2006-11-16   荐:
字符串搜索的问题我一个表 表名是 safe 下面有8个字段 我想搜索 在字段中包含 "abc"字符串的所有内容例如有 abc abcde abcdefg efg搜索以后除efg 其他的都能都能搜索到. ''' (0 0) -----oOO----(_)------------ | | | 俺发现俺越来越罗嗦了! | | | | | ------------------oOO------ |__|__| || || ooO Oooselect * from safe where a like '玞%' or b like '玞%' or...都包含"abc"呀!不明白。select * from safe where a like '玞%' 模糊查询我提供了一个符合条件的字符串为什么就是不会出结果郁闷中.以下是代码:==========================using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;namespace serch{/// <summary>/// ShowSeach 的摘要说明。/// </summary>public class ShowSeach : System.Web.UI.Page{protected System.Web.UI.WebControls.DataGrid DataGrid1;protected System.Web.UI.WebControls.Label Label1;private void Page_Load(object sender, System.EventArgs e){// 在此处放置用户代码以初始化页面string sql;string str=Request["mystr"];string table=Request["tablename"];DataSet ds=new DataSet();string strconn="server=(local);uid=pds;password=;database=pdssme";SqlConnection myconn=new SqlConnection(strconn);myconn.Open();SqlDataAdapter rs;switch(table){case "corp":sql="select * from pds.corp where corp_name like '" str "' or main_business like '" str "' or corp_addr like '" str "' or corp_phone like '" str "' or fax like '" str "' or post_code like '" str "' or corp_email like '" str "' or corp_picture like '" str "'or website like '" str "'or fee_phone like '" str "'or brief like '" str "'";rs=new SqlDataAdapter(sql,myconn);rs.Fill(ds,"corp");DataGrid1.DataSource=ds.Tables["corp"].DefaultView;DataGrid1.DataBind();break;case "product":sql="select * from product where pds.prod_name like '" str "'or model like '" str "' or specification like '" str "'and patria like '" str "'or package like '" str "'or introduction like '" str "'or reserver like'" str "'";rs=new SqlDataAdapter(sql,myconn);rs.Fill(ds,"product");DataGrid1.DataSource=ds.Tables["product"].DefaultView;DataGrid1.DataBind();break;default:Response.Write("没有符合查询条件的数据!");break;}}#region Web 窗体设计器生成的代码override protected void OnInit(EventArgs e){//// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。//InitializeComponent();base.OnInit(e);}/// <summary>/// 设计器支持所需的方法 - 不要使用代码编辑器修改/// 此方法的内容。/// </summary>private void InitializeComponent(){ this.Load = new System.EventHandler(this.Page_Load);}#endregion}}===================== ''' (0 0) -----oOO----(_)------------ | | | ~~~`郁闷中~~思考中~~~ | | | | | ------------------oOO------ |__|__| || || ooO Ooo老大们,你们怎么不回答呀我自己顶,我急用呀 ''' (0 0) -----oOO----(_)------------ | | | 急~~~~急~~~~急~~~~ | | | | | ------------------oOO------ |__|__| || || ooO Ooo
标签: