我已使用内置向导功能编程了我的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
任何帮助都会很棒!
答案 0 :(得分: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