本帖最后由 haodd 于 2011-9-3 09:27 编辑
已解决 把 创建(GUICtrlCreateProgress ) 和 数据设置 (GUICtrlSetData )分开写 创建GUICtrlCreateProgress 只需要一次即可!
下面是错误的例子!
Func _SelectSQL()
$sServer = "10.10.10"
$sUsername = "sa"
$sPassword = "***"
$sDatabase = "DB" ;库名
$sTable = "Count" ;表
$adodb = ObjCreate("ADODB.Connection")
$adodb.Open("driver={SQL Server};server=" & $sServer & ";uid=" & $sUsername & ";pwd=" & $sPassword & ";database=" & $sDatabase & "")
$RS2 = ObjCreate("ADODB.Recordset")
$RS2.ActiveConnection = $adodb
$RS2.Open("SELECT * FROM LinkCount")
Dim $Count = 1;定义一个变量用来记录查询到的数据行数
Dim $L = 72
While Not $RS2.eof And Not $RS2.bof
If @error = 1 Then ExitLoop
ReDim $Name[$Count + 1],$Count[$Count + 1],$Progress[$Count + 1]
$Name[$Count] = GUICtrlCreateLabel($RS2.Fields("字段1").Value, 16, $L, 52, 17)
$Count[$Count] = GUICtrlCreateLabel($RS2.Fields("字段2").Value, 80, $L, 36, 17)
$Progress[$Count] = GUICtrlCreateProgress(128, $L, 122, 16,BitOR($PBS_SMOOTH, $WS_CLIPSIBLINGS))
;~ GUICtrlSetColor($Progress[$Count], 0x73D73A)
GUICtrlSetData($Progress[$Count],Number($RS2.Fields("统计").Value)/$Refer*100)
$DBtime = $RS2.Fields("时间").value
$L += 24
$Count += 1
$RS2.movenext
WEnd
$RS2.Close
$adodb.Close
;~ $rows = UBound($Select_Db)
;~ _ArrayDisplay($Select_Db)
$Label2 = GUICtrlCreateLabel("刷新时间:" & @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, 16, 10, 200, 17)
;~ $Label3 = GUICtrlCreateLabel("数据时间:" & _format_time($DBtime), 16, 30, 200, 17)
EndFunc ;==>_SelectSQL
程序运行 显示的进度条
更改数据库里面的值后,能正确读取到修改的值27222,但是进度条却没有正常刷新
请教 怎么回事? |