HOW TO USE: BackgroundWorker
Hi,
Anybody here can help me please. If I execute the function below, and the records was all up to 20K, my program is not responding. The function is used to get the total rows within the date range on my criteria. I am using FireBird database. I overheard that using BackgroundWorker will do, but I really don't have an idea on how to use it.
Where do I use the BackgroundWorker in my code as follows:
Example:
PrivateFunction GetTotalRows()AsInteger
Dim dQueryAs DateTimeDim dStartAs DateTime =Me.dtpFrom.Value.DateDim dEndAs DateTime =Me.dtpTo.Value.Date
Try
iCtr = 0
' Loop through database record
SQL(
"SELECT * FROM logrecord")If Dr.HasRows =TrueThenDoWhile Dr.Read
CDate(Dr.Item("logdate").ToString)dQuery =
If dQuery.Date >= dStart.DateAnd dQuery.Date <= dEnd.DateThen
EndIfLoopEndIfiCtr = iCtr + 1
iRowCount = iCtr
' Clean
Dr.Close()
Cmd.Dispose()
Catch exAs SqlException
MsgBox(ex.ToString, MsgBoxStyle.Critical,"ODBC Error")
Catch exAs Exception
MsgBox(ex.ToString, MsgBoxStyle.Critical,"General Error")
EndTry
Return iRowCount
EndFunction
Thanks![]()

