【发布时间】:2020-06-02 15:57:23
【问题描述】:
我正在实施一个系统,在该系统中,我想在 datagridview 中的文本框中更改文本时搜索产品。我已经完成了那部分。
但我发现搜索命令只能帮助我找到单元格的产品第一个单词。但我想用任何选定的单元格过滤它。
示例:
在我的datagridview 中有一个列Product Name。在该列中,有一个数据为 Galaxy A20s。目前,我必须在我的搜索文本框中输入以 Galaxy.... 开头的内容,然后才会出现搜索结果。我想修改输出,比如如果我输入 A20s 那么结果也应该在 datagridview 中过滤。
在 vb.net 中执行此操作的任何可能性。
这是我目前正在使用的代码。
Try
con = New OleDbConnection(cs)
con.Open()
cmd = New OleDbCommand("SELECT (ProductID) as [Product ID],(ProductName) as [Product Name],(Brand) as [Brand],(UnitPrice) as [Unit Price] from ProductDB where ProductName like '" & txtSearch.Text & "%' order by ProductName", con)
Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "ProductDB")
dgFillProduct_Stock.DataSource = myDataSet.Tables("ProductDB").DefaultView
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
谢谢
【问题讨论】: