[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL calculated field not showing in ASP page

Posted on 2004-09-03
3
Medium Priority
?
234 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 800 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

649 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