This topic is locked

Declare a session variable

7/14/2008 10:04:14 AM
ASPRunnerPro General questions
jfr author

Hello,
The following;
On of my reports shows the specific order for a customer.
This report shows a total amount. For this total amount I want to calculate what it'll cost the customer if he doesn't buy, but wants to rent.
I have created the view (Huurcalculatue) which does the calculation.

This calculation is based on Order_id.
Below is the SQL query.

SELECT mnd_24

FROM Huurcalculatue

WHERE (Order_id = 44)


And this is what I had put together for the presentation within ASP Runner

dim rs

FieldName = "mnd_24"

set rs = server.createobject("ADODB.Recordset")
rs.open "Select " & FieldName & " from " & "dbo.Huurcalculatue" & " where " & "dbo.Huurcalculatue.Order_id=" & " & Session("[b]Forecast_detail_totaal_view.Order_id[/b]") , dbConnection
Response.Write "mnd_24"


But of course is Forecast_detail_totaal_view.Order_id not a known Session Variable.
The question is thus, how can I capture the Order_id of the Order?
Thanks a lot,

John

J
Jane 7/15/2008

John,
where do you use this code?

jfr author 7/15/2008

Jane,
On the visual editor.
John

J
Jane 7/16/2008

John,
do you use this code in the custom event on the list page or on the view/edit pages?

jfr author 7/16/2008

Jane,
I use this on the Listing page, sorry for not being to clear.

J
Jane 7/16/2008

Hi,
use List page: Before SQL query event to declare and fill new Session variable.

Here is a sample:

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open strSQL,dbConnection

Session("Order_id") = rsTemp("Order_id")

rsTemp.close

set rsTemp=nothing

jfr author 7/17/2008

Hi Jane,
The session variable declaration works fine.
Now for the last help on this one, can you please verify this code, since this gives an End of Statement Error.

dim rs

FieldName = "mnd_24"

set rs = server.createobject("ADODB.Recordset")
rs.open "Select " & FieldName & " from " & "dbo.Huurcalculatue" & " where " & " Order_id=" & " & Session("Order_id") , dbConnection
Response.Write rs("mnd_24")

rs.close


Thanks a lot Jane,

John

J
Jane 7/18/2008

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

jfr author 7/22/2008

Jane,
Working <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=31299&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />

dim rs

FieldName = "mnd_24"

set rs = server.createobject("ADODB.Recordset")
rs.open "Select " & FieldName & " from " & "dbo.Huurcalculatue" & " where " & " Order_id=" & Session("Order_id") , dbConnection
Response.Write rs("mnd_24")

rs.close


The great thing is that now the Print page shows besides the Order Total, also shows the rent amount for 24/36/48/60 months.


Thanks a lot,

John