# Re: vb6好慢...如何加快?t.k.s.

Posted by andyLin on October 31, 1999 at 22:28:41:

In Reply to: vb6好慢...如何加快?t.k.s. posted by daniel on October 31, 1999 at 20:15:00:

: Set rs2 = db.OpenRecordset("人事资料表", dbOpenDynaset)
: If rs2.RecordCount <> 0 Then
: rs2.MoveFirst
: while not rs2.eof
: sql = "select * from 员工请假表 where 工号='" & rs2![工号] & "'" & " and " & "year(请假日期)-1911=" & Val(Left$(mstryymm, 2)) & " and " & "month(请假日期)=" & Val(Right$(mstryymm, 2))
: Set rs3 = db.OpenRecordset(sql, dbOpenDynaset)
: If rs3.RecordCount <> 0 Then
: rs3.MoveFirst
: While Not rs3.EOF
: .
: .
: rs3.MoveNext
: Wend
: End If
: '
: sql = "select * from 员工加班表 where 工号='" & rs2![工号] & "'" & " and " & "year(请假日期)-1911=" & Val(Left$(mstryymm, 2)) & " and " & "month(加班日期)=" & Val(Right$(mstryymm, 2))
: Set rs4 = db.OpenRecordset(sql, dbOpenDynaset)
: If rs4.RecordCount <> 0 Then
: rs4.MoveFirst
: While Not rs4.EOF
: .
: .
: rs4.MoveNext
: Wend
: End If
: '
: .
: .
: rs2.MoveNext
: wend
: endif

慢的原因是因为你的程式与资料库沟通太多次了,不管是用何种语言设计都会慢,并不是vb 之问题,你应该分析员人事资料表与员工请假,员工加班之间关连在何处,利用join 之与法将其一次取出,若无关连则应该在系统分析时要做好规划,否则在日后做报表时会非常吃力且速度会很慢,以上仅供参考..

Follow Ups: