Go Back  Xtreme Visual Basic Talk > Other Languages > Web Programming > Getting invalid results, please help!!!!


Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2006, 10:38 AM
kenig kenig is offline
Regular
 
Join Date: Mar 2005
Posts: 96
Default Getting invalid results, please help!!!!


Hello, again good people.

I am having a major issues.

Please take a look at this link first:

http://keniginc.com/defaultsc.htm

All items on left starting with Bal. From Prev Month are called ActivityType on our db.

All the items on the right, starting with PLA to DOMESTIC, are caseType on our db.

What I want to do is take each row, and get a value for all 5 casetypes, then add the values and stick the total in the TOTAL column in extreme right.

So far, the values are not right.

Take for instance, the following:

ActivityType CaseType Count
1 1 3
1 2 5
1 3 6
1 4 8
1 5 9

The above means that ActivityType here is Bal.From Prev. Month and has a value of 1
CaseTypes are PLA, CASE, SILICA, CIVIL, DOMESTIC, 1,2,3,4,5 respectively.

And PLA has a value of 3 (count)
CASE has a value of 5
SILICA has a value of 6
CIVIL has a value of 8
DOMESTIC has a value of 9

I expected the code snippet below to get these values right and stick them in those input textboxes. Those boxes are either blank or have the wrong values.

Here is my code snippet.
Code:
<TR> <TD nowrap align="left">Bal. From Prev. Month</TD> <% activity = 0 For casetype = 1 TO 5 data = "" If Not eachRowRS.eof Then If eachRowRS("activityType") = activity AND eachRowRS("caseType") = casetype Then data = eachRowRS("count") eachRowRS.MoveNext End If End If %> <TD><input size="5" name="count_<%=activity%>_<%=casetype%>" value="<%=data%>"></TD> <% Next %> <TD><input size=5 name="total_<%=activity%>" READONLY></TD> </TR>

This is for one row and is supposed to feel all those boxes in the Bal. From Prev Month row.

Any assistance is greatly, appreciated.
Reply With Quote
  #2  
Old 12-18-2006, 12:13 PM
wayneph's Avatar
wayneph wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

Personally, I'd change your query. Instead of looping through rows to generate columns on the asp side, I'd pivot the table in your SQL Statement. The syntax for that will be different depending on what type os database you have, but it shouldn't be too hard. (In some databases it's called a Crosstab query.)
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #3  
Old 12-18-2006, 12:23 PM
kenig kenig is offline
Regular
 
Join Date: Mar 2005
Posts: 96
Default

Thanks, Wayne!

I will research crosstabs for SQL Server
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->