Solved

SQL calculated field not showing in ASP page

Posted on 2004-09-03
3
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

726 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