|
-
Jul 14th, 2004, 11:25 AM
#2
Re: Looping process with datareader
Originally posted by Winanjaya
Dear The Expert,
I don't understand .. why my looping process below (with level break condition) does not working ..I meant the "mTotalFreq" always has incorrect value.. it seems like the looping process has skipped one or some records, am I missing something?
DataReader = Cmd.ExecuteReader
While DataReader.Read
mStat = DataReader("Stat")
mHostCode = DataReader("HostCode")
While DataReader.Read = True And DataReader"HostCode") = mHostCode
mTotalFreq = mTotalFreq + DataReader("TotalCost")
End While
End While
DataReader.Close()
SQLTemp.Close()
I need advise .. many thanks in advance
Regards
Winanjaya
Yes you're missing something. Everytime you do the DataReader.Read, it moves to the next record. So you are getting an incorrect value.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|