ASP.net MS访问类似查询无法使用asp.net c#

时间:2016-07-07 11:02:40

标签: javascript css asp.net ms-access

所有类似查询都不起作用请帮助我,下面是我的代码。

string Item_Name = txt_search.Text.Trim();
string Conn = ConfigurationManager.ConnectionStrings["AjitConnectionString"].ToString();
OleDbConnection con = new OleDbConnection(Conn);
con.Open();
OleDbCommand cmd;
cmd = new System.Data.OleDb.OleDbCommand("select * from [Item] where [Name] like '*'+inamer_Name+'*'", con);
cmd.Parameters.AddWithValue("@inamer_Name", Item_Name);
cmd.ExecuteNonQuery();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
grid_itemedit.DataSource = dt;
grid_itemedit.DataBind();
con.Close();

1 个答案:

答案 0 :(得分:1)

外卡字符是比较字符串的一部分 For example

  

喜欢'b *'
  结果:所有以b

开头的值
cmd = new System.Data.OleDb.OleDbCommand("select * from [Item] where [Name] like '%" + inamer_Name + "%'", con);