找回密码
 加入
搜索
楼主: hhasee

如何读取数据库中的总纪录数?

[复制链接]
发表于 2009-6-3 09:46:40 | 显示全部楼层
囧囧有神!还有这种情况啊
噶你就判断下饿
if $i > 1000 then
$f = $i -1
else
$f = $i
endif
发表于 2009-6-3 10:58:15 | 显示全部楼层
15# hhasee

这个是我的一个小程序中的一个函数,可以返回一个查询记录的笔数,看是否有用。
Func query()
        $view3 = ""
        GUICtrlSetData($Label5,$view3)
        $txt0 = GUICtrlRead($input1);输入查询条件
        $txt1 = GUICtrlRead($Combo1);*
        $txt2 = GUICtrlRead($Combo2);table name
        $txt3 = GUICtrlRead($Combo3);字段
        GUICtrlSendMsg($ListView3 , $LVM_DELETEALLITEMS, 0, 0)
        $addfld = ObjCreate("ADODB.Connection")
        $addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password= b0061311")
        $RS =ObjCreate("ADODB.Recordset")
        $RS.ActiveConnection = $addfld
        Dim $fieldname,$match
        If $txt3 = "厂别" Then $fieldname = "plant"
        If $txt3 = "OA编号" Then $fieldname = "pc_number"
        If $txt3 = "资产编号" Then $fieldname = "asset_number"
        $RS.open("select "&$txt1&" from  "&$txt2&" where "&$fieldname& "= '"&$txt0&"'")
        $i = 0
        while Not $RS.eof And Not $RS.bof
                if @error =1 Then ExitLoop
                $item3 = GUICtrlCreateListViewItem($RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (3).value&"|"& $RS.Fields (4).value&"|"& $RS.Fields (5).value&"|"& $RS.Fields (6).value&"|"& $RS.Fields (7).value&"|"& $RS.Fields (8).value&"|"& $RS.Fields (9).value&"|"& $RS.Fields (10).value&"|"& $RS.Fields (11).value,$ListView3)
                GUICtrlSetColor($item3, 0x008000);<==设置Item项里字体颜色
                $i = $i + 1
                $rs.movenext
        WEnd
        If $i= 0 then
                MsgBox(0,"提示","无数据返回!请确认输入!")
        Else
                $view3 = "共找到"&$i&"笔记录"
                GUICtrlSetData($Label5,$view3)
        EndIf
        $rs.close
        $addfld.Close
EndFunc
 楼主| 发表于 2009-6-3 14:08:56 | 显示全部楼层
本帖最后由 hhasee 于 2009-6-3 14:12 编辑

没有人有解决方案了吗?以上的方案都无法从根本上解决问题啊!!~~
发表于 2009-6-11 17:47:48 | 显示全部楼层
$RS=$conn.Execute("SELECT Count(*) AS c FROM 表名")
$RS.Fields (0).value 应该可以得到记录数

如果用$rs来打开的话,$rs.RecordCount应该就是记录数
发表于 2009-6-11 19:16:04 | 显示全部楼层
看不懂.......
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 02:23 , Processed in 0.065853 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表