求助:关于实时更新datagrid
大家好,最近在做个实例,想让datagrid的数据表,按搜索框的内容,实时显示过滤的数据,但我的搜索框输入时,datagrid并没有响应。请大家帮忙看看,我要怎么要,才能实现啊?
程序代码:
'窗体加载时 Private Sub Form_Load() '''连接数据库 filename = App.Path & "\database\database.mdb" dbpass = "123456qwerty" dbpd = ";Jet OLEDB:Database Password=" & dbpass & ";admin,111" cnstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filename & dbpd cnn.Open cnstr '''显示数据集合 Set rs = New adodb.Recordset rs.CursorType = adOpenKeyset rs.LockType = adLockOptimistic rs.CursorLocation = adUseClient Select Case SSTab1.Tab Case 0 '如果在第一个TAB,加载开发项目的数据库 cnsql = "select * from a_partinfo" rs.Open cnsql, cnn '''设置datagrid控件 Set DGrid1.DataSource = rs DGrid1.AllowAddNew = False DGrid1.AllowDelete = False DGrid1.AllowUpdate = False DGrid1.Refresh '''设计选择列表 Combo1.AddItem "产品型号" Combo1.AddItem "客户名称" Combo1.Text = Combo1.List(0) Case 1 Case 2 End Select End Sub Private Sub txtsou_Change() Dim cnsql As String cnsql = "select * from a_partinfo where 产品型号 like+ '" + txtsou.Text + "'+'%'" DGrid1.Refresh End Sub