Solved

SQL calculated field not showing in ASP page

Posted on 2004-09-03
3
229 Views
Last Modified: 2006-11-17
Hi All,
I am running into a weird problem. I have a SQL that generates results which include a calculated field:

SELECT       
A_Items.*,
A_Prices.Price,
'CalculatedPrice' =
  CASE
    WHEN sp_Action_Flag = 'P' THEN (A_Prices.Price - (A_Prices.Price * sp_Action_Amount))
    WHEN sp_Action_Flag = 'F' THEN (A_Prices.Price - sp_Action_Amount)
    WHEN sp_Action_Flag = 'L' THEN (sp_Action_Amount)
    ELSE A_Prices.Price
  END

In SQL Query Analyzer and in the test results of Dreamweaver the results come back fine. However, when I actually view the page in a browser it doesn't show the A_Prices.Price. For example:

<%=rsItems("CalculatedPrice")%><br />
<%=rsItems("Price")%><br />

This displays the correct value for rsItems("CalculatedPrice") but displays nothing for rsItems("Price"). If I flip the two around, it all works:

<%=rsItems("Price")%><br />
<%=rsItems("CalculatedPrice")%><br />

Is there a reason I cannot access the information in PRICE if CALCULATEDPRICE is referrenced first? Is there a work around or better way to do this without having to displayed my SQL generated result last? I'm mean, I can always do the calculation in ASP and bypass the SQL, but that's so much more convenient. Is there just a limitation when I want to do this stuff in SQL? Thanks!

I'm running Windows 2000 Server and MS SQL Server 2000 Developers Edition.

RJ
0
Comment
Question by:ramyar
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
darksinclair earned 200 total points
ID: 11976407
This is a shot in the dark.. and perhaps this isnt the best place to be doin it,, but I had a problem similar to this... mine was resolved by adding cursor types onto the end of my recordset Open...

Is your recordset defined currently as :  rsItems.Open SQL, Conn ?

If so, try to change it to rsItems.Open SQl, Conn, 2, 3 .. I think this might have something to do with the way the recordset is opened.

Cheers,
0
 

Author Comment

by:ramyar
ID: 11978895
Thanks Darksinclair!
Your advice led me down the right path. I set my CursorType to 3 (I usually explicitly call my recordsets) and it worked! For anyone else interested, I also found these websites informational:

http://www.psacake.com/web/et.asp
http://www.4guysfromrolla.com/webtech/112998-1.shtml

RJ
0
 
LVL 5

Expert Comment

by:darksinclair
ID: 11980189
no problem ramyar,, I know I spent a good half day trying to figure out my problem... Your's just seemed to ring a bell and I had a good feeling :)

Cheers M8t, Happy Coding!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
syntax error on ASP ? 6 46
Add server behaviors to Dreamweaver CC 2015 2 154
asp syntax 3 49
One field not displaying content (ASP Classic) 8 22
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now