0

我已经对我的 datagridview 连接进行了编程,而不是使用内置的向导功能。我现在遇到的唯一问题是我似乎无法在我键入时通过 SQL 过滤器搜索绑定源。我的意思是,当我在文本框中键入时,我想过滤我的数据库的“SkuNo”列的数据,如数据网格上所示。这非常简单,并且与向导一起工作得很好,但我正在努力通过代码做到这一点。这是我的代码:

 Private Sub txtSearchOnSku_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearchOnSku.TextChanged
    Dim source1 As New BindingSource()

    DataGridView1.DataSource = source1

    source1.Filter = "skuNo LIKE'" & txtSearchOnSku.Text & "*'"
End Sub
End Class

任何帮助都会很棒!

4

1 回答 1

0

好的,伙计们

继承人的代码:

Dim sql As String = "SELECT * FROM duragadget"
Dim connection As New OleDbConnection(duraGadgetDB)
Dim dataadapter As New OleDbDataAdapter(sql, connection)
Dim ds As New DataSet()
Dim dsView As New DataView
Dim bs As New BindingSource()
connection.Open()
dataadapter.Fill(ds, "dura")
connection.Close()
dsView = ds.Tables(0).DefaultView
bs.DataSource = dsView
bs.Filter = "skuNo LIKE'" & txtSearchOnSku.Text & "*'"
DataGridView1.DataSource = bs
于 2013-01-04T21:15:53.913 回答