所有类似查询都不起作用请帮助我,下面是我的代码。
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();
答案 0 :(得分:1)
外卡字符是比较字符串的一部分 For example:
喜欢'b *'
开头的值
结果:所有以b
cmd = new System.Data.OleDb.OleDbCommand("select * from [Item] where [Name] like '%" + inamer_Name + "%'", con);