I know you got the solution - but wanted to point out something - if the ONLY reason you are fetching the data is to get the top payment mode, then you should do it in the Select query and not after ALL the rows are fetched. Shreekar http://shreekarishere.blogspot.com