VB显示搜索字段的条数

来源:百度知道 编辑:UC知道 时间:2024/04/29 09:24:25
我用VB做了一个索引,ADODB.Recordset,比如说我搜索access学籍(xj)表里的性别(男),然后会显示出所有该表中男生的信息,我想加个text或lable来显示总共有多少个男生(男生记录总条数有多少),英语系的男生多少人(也就是英语系的男生记录条数,系别是xj表里的字段),机械系的男生有多少人,然后text1显示的是男生总人数,text2显示的是英语系男生人数,在拉个text3用来显示英语系男生比上男生总数,求出英语系男生在学校男生中的比例...请各位指教!!!!
不行啊,我在模块里定义public zongshu as integer 然后在窗体中敲的代码为"zongshu = "select count(性别) from xj where 性别='男'"
Text1.Text = zongshu 但是在text1中显示的是"select count(性别) from xj where 性别='男'"这句话...我没加datagrid控件...全是用ado语句链接的数据库...用语句赋值代换得怎么实现啊???拜托!!!毕业3年学的东西全忘光了.
大哥,我必须给你加分.结果出来了.不过要想再建立3个text,显示多条记录条数改怎么添加?Adodc1.RecordSource = "select count这条语句只搜索一个性别,在继续搜索各个系别得在select count前面加什么?Adodc1.RecordSource貌是不灵...然后text2.text=datagrid1.columns(1).text???

select count(性别) from xj where 性别='男'
select count(性别) from xj where 性别='男' and 系别='英语系'
select count(性别) from xj where 性别='男' and 系别='机械系'
把他们依次在datagrid里显示,再赋值给text
------------------------------------------------------------------------
添加gatagrid1,datasourse手动设置为adodc1
添加text1
rivate Sub Form_Load()

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_books.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select count(性别) from xj where 性别='男'"
Adodc1.Refresh
text1.text=datagrid1.columns(0).text
End Sub