如何按关键字过滤datagridview?

时间:2013-08-29 22:38:45

标签: c# search datagridview oledb filtering

我希望使用C#和Textbox在访问文件中搜索DataGridView中的关键字,我的代码位于下方,但错误“缺少操作数”;

BindingSource bs = new BindingSource();
bs.DataSource = dataGridView1.DataSource;
bs.Filter = "select * FROM book WHERE onvan like '*" + textBox1.Text + "*'";
dataGridView1.DataSource = bs;

1 个答案:

答案 0 :(得分:-1)

您无法将完整的选择查询作为bindingsource的过滤器传递。试试这个

bs.Filter = "onvan like '*" + textBox1.Text + "*'";

并查看此链接以获取更多信息:BindingSource.Filter