2013-08-29 192 views
-1

我想在C#和DataGridView的訪問文件中搜索Textbox的關鍵字,我的代碼在下面,但有錯誤「缺少操作數」的問題;如何通過關鍵字過濾datagridview?

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

回答

-1

您無法將完整的選擇查詢作爲您的bindingsource的過濾器。試試這個代替

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

並檢查此鏈接的更多信息:BindingSource.Filter