在datagridview中过滤记录集 [英] filter recordset in datagridview

查看:80
本文介绍了在datagridview中过滤记录集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rs.Open(从vprtywrk中选择不同的prtynm",骗局,ADODB.CursorTypeEnum.adOpenKeyset,ADODB.LockTypeEnum.adLockOptimistic)
i = 0
虽然不是rs.EOF
DataGridView2.RowCount = DataGridView2.RowCount + 1
DataGridView2.Item(0,i).Value = rs.Fields("prtynm").Value
rs.MoveNext()
我=我+1
结束时
rs.Close()

如何过滤呢?
如果我有一个文本框,然后在其中输入一些文本.然后网格将基于文本框中的字符串进行过滤.

rs.Open("select distinct prtynm from vprtywrk", con, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
i = 0
While Not rs.EOF
DataGridView2.RowCount = DataGridView2.RowCount + 1
DataGridView2.Item(0, i).Value = rs.Fields("prtynm").Value
rs.MoveNext()
i = i + 1
End While
rs.Close()

how to filter this ?
if i have one textbox and i enter some text in that. then grid will be filter based on that string in textbox

推荐答案

"select distinct prtynm from vprtywrk where prtynm = '" & textbox1.text & "'" 

-您可以在此部分中放置where子句,以引用喜欢什么的字段我做到了prtynm是数据库中的字段,textbox1是用于过滤将显示在datagrid上的记录的文本框

您也可以尝试这个

- you can put where clause in this part referencing the field that like what i did. prtynm is the field in your database and textbox1 is the textbox that you are using to filter the records that will be shown on your datagrid

you can also try this one

"select distinct prtynm from vprtywrk where prtynm like '%" & textbox1.text & "%'" 



问候,

约翰



Regards,

John


这篇关于在datagridview中过滤记录集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆