|
发表于 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 |
|