I have a question...I have a javaservlet that reads a database and totals up a field off of the database and produces a total dollar amount here is the code...
And this works but if the field contains the same payable amount (example 150.00 is the payable amount for two fields) the amounts are not added together. Am I missing something? [ October 03, 2005: Message edited by: Mark Spritzler ]
First I used the CODE tags and added indention to make it more readable.
For the inner most if statement there was no curly braces since I assume it was a one line after, but that makes code very unreadable and therefore easy to have problems not knowing which lines of code would run, which probably is leading to your actual problem.
So now, there is a curly brace missing based on probably putting in the curly braces in the wrong place, since it is unreadable to really know.
So please fix where the curly braces should go and you should always use curly braces even with a single line if statement.
Originally posted by D Wynn: ... if the field contains the same payable amount (example 150.00 is the payable amount for two fields) the amounts are not added together
Are you sure that your recordset actually contains duplicate copies of these values? Depending on your query, which you have not shown us, it might only return single instances for duplicate lines. Put some print statements in your loop to confirm that the recordset contents are what you expect.
Also, is there a reason for retrieving all the records, and then adding them up? A better approach would be to do the totalling in the database query.
Joined: May 03, 2004
It was only bringing back one copy of the value so I did a sum of the column in my query and it works!! Thanks for your help. I still wonder why my query wouldn't bring back both copies of the duplicate value??