By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,637 Members | 1,967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,637 IT Pros & Developers. It's quick & easy.

asp variables not displaying

P: n/a
Hello All

I have an asp page in which I am performing the following

1. Querying a database view
2. Returning rows in to a recordset.
3. Looping thru the recordset and printing the data
4. Before displaying the data I am assigning the values from the recordset
into variables
5. There are 2 entry points to this page both of which would run similar
queries and return similar results

My problem is that for a certain sequence of variable assignments, my data
is not displaying on the screen (even though when i do a response.write I
see that the variable actually has a value in it). In order to fix it I
rearranged the sequence of assignments but since I have two entry points to
the page, it didnot display the data for the other entry point

Can anyone help with a suggestion/solution

Thank you
Jul 19 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Perhaps if you post the relevant section of your code.

Ray at work

"Rahul Chatterjee" <ra***@benesysinc.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Can anyone help with a suggestion/solution

Jul 19 '05 #2

P: n/a
Perhap if you showed your code, we could make a suggestion, as it is it's a
little difficult to guess what the problem is.

"Rahul Chatterjee" <ra***@benesysinc.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hello All

I have an asp page in which I am performing the following

1. Querying a database view
2. Returning rows in to a recordset.
3. Looping thru the recordset and printing the data
4. Before displaying the data I am assigning the values from the recordset
into variables
5. There are 2 entry points to this page both of which would run similar
queries and return similar results

My problem is that for a certain sequence of variable assignments, my data
is not displaying on the screen (even though when i do a response.write I
see that the variable actually has a value in it). In order to fix it I
rearranged the sequence of assignments but since I have two entry points to the page, it didnot display the data for the other entry point

Can anyone help with a suggestion/solution

Thank you

Jul 19 '05 #3

P: n/a
Here it is. This query is populated by a select * from tablename query.
All vars return values when we do response.write to see but does not
display when just output plainly.

Please advise

if not rsDetails.eof then
rsDetails.movefirst
prevProjectID = rsDetails("ProjectID")
do while not rsDetails.eof

ProjectID = rsDetails("ProjectID")
WorkDt = rsDetails("WorkDt")
EstHrs = cint(rsDetails("EstHrs"))
Hours = rsDetails("Hours")
Details = rsDetails("Details")
Initials = rsDetails("Initials")
Billed = rsDetails("Billed")

if prevProjectID = ProjectID then%>
<tr>
<td valign="top" align="center" width="114"><%=ProjectID%></td>
<td valign="top" width="26"><%=WorkDt%></td>
<td valign="top" align="center" width="65"><%=Initials%></td>
<td valign="top" align="center" width="66"><%=EstHrs%></td>
<%hrAccum = hrAccum + Hours%>
<td valign="top" width="22"><%=Hours%></td>
<%HrDiff = EstHrs - Hours%>
<td valign="top" align="center" width="66"><b><%=HrDiff%></b></td>

<%Details = replace(Details, "&quot;", "'")%>
<td valign="top" width="300"><%=Details%></td>
<%if Billed <> "" then
if Billed = 1 then%>
<td valign="top" align="center" width="34">Y</td>
<%else%>
<td valign="top" align="center" width="12">N</td>
<%end if%>
<%else%>
<td valign="top" align="center" width="12">N</td>
<%end if%>
</tr>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4

P: n/a
Do you see them in a view source? It sounds like it's an HTML problem.
Like, you're saying you WOULD see the value if:

<%

response.write ProjectID

%>

but you don't see it in :
<td valign="top" align="center" width="114"><%=ProjectID%></td>

?

What's in the html source?

Ray at work

"Rahul Chatterjee" <an*******@devdex.com> wrote in message
news:uU**************@TK2MSFTNGP11.phx.gbl...
Here it is. This query is populated by a select * from tablename query.
All vars return values when we do response.write to see but does not
display when just output plainly.

Please advise

if not rsDetails.eof then
rsDetails.movefirst
prevProjectID = rsDetails("ProjectID")
do while not rsDetails.eof

ProjectID = rsDetails("ProjectID")
WorkDt = rsDetails("WorkDt")
EstHrs = cint(rsDetails("EstHrs"))
Hours = rsDetails("Hours")
Details = rsDetails("Details")
Initials = rsDetails("Initials")
Billed = rsDetails("Billed")

if prevProjectID = ProjectID then%>
<tr>
<td valign="top" align="center" width="114"><%=ProjectID%></td>
<td valign="top" width="26"><%=WorkDt%></td>
<td valign="top" align="center" width="65"><%=Initials%></td>
<td valign="top" align="center" width="66"><%=EstHrs%></td>
<%hrAccum = hrAccum + Hours%>
<td valign="top" width="22"><%=Hours%></td>
<%HrDiff = EstHrs - Hours%>
<td valign="top" align="center" width="66"><b><%=HrDiff%></b></td>

<%Details = replace(Details, "&quot;", "'")%>
<td valign="top" width="300"><%=Details%></td>
<%if Billed <> "" then
if Billed = 1 then%>
<td valign="top" align="center" width="34">Y</td>
<%else%>
<td valign="top" align="center" width="12">N</td>
<%end if%>
<%else%>
<td valign="top" align="center" width="12">N</td>
<%end if%>
</tr>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #5

P: n/a
I assume that you have
1) rsDetails.MoveNext and Loop somewhere
2) a table opening tag

Does it send anything? If you view source do you see anything?
As you have "everything" within the
If prevProjectID=ProjectID
structure, do you close it somewhere(end if) , do you set prevProjectID
somewhere? If not, then you'll only get the first ProjectID's information.
If that's what you want, you'd be better off rewriting your SQL Select
statement

I don't think there's any need to movefirst.
From the code you've shown, there doesn't appear to be anything wrong,
assuming that the rest of the page is right.

"Rahul Chatterjee" <an*******@devdex.com> wrote in message
news:uU**************@TK2MSFTNGP11.phx.gbl...
Here it is. This query is populated by a select * from tablename query.
All vars return values when we do response.write to see but does not
display when just output plainly.

Please advise

if not rsDetails.eof then
rsDetails.movefirst
prevProjectID = rsDetails("ProjectID")
do while not rsDetails.eof

ProjectID = rsDetails("ProjectID")
WorkDt = rsDetails("WorkDt")
EstHrs = cint(rsDetails("EstHrs"))
Hours = rsDetails("Hours")
Details = rsDetails("Details")
Initials = rsDetails("Initials")
Billed = rsDetails("Billed")

if prevProjectID = ProjectID then%>
<tr>
<td valign="top" align="center" width="114"><%=ProjectID%></td>
<td valign="top" width="26"><%=WorkDt%></td>
<td valign="top" align="center" width="65"><%=Initials%></td>
<td valign="top" align="center" width="66"><%=EstHrs%></td>
<%hrAccum = hrAccum + Hours%>
<td valign="top" width="22"><%=Hours%></td>
<%HrDiff = EstHrs - Hours%>
<td valign="top" align="center" width="66"><b><%=HrDiff%></b></td>

<%Details = replace(Details, "&quot;", "'")%>
<td valign="top" width="300"><%=Details%></td>
<%if Billed <> "" then
if Billed = 1 then%>
<td valign="top" align="center" width="34">Y</td>
<%else%>
<td valign="top" align="center" width="12">N</td>
<%end if%>
<%else%>
<td valign="top" align="center" width="12">N</td>
<%end if%>
</tr>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #6

P: n/a
Are you seeing everything but the values then, or perhaps you're not seeing
anything because your IF condition is never true. What happens if you put
something else in the td's with the variables so you can be sure that you're
seeing the table fully and everything.

---------------------
if prevProjectID = ProjectID then%>
<tr>
<td valign="top" align="center" width="114">Project ID = <%=ProjectID%></td>
<td valign="top" width="26">WorkDT = <%=WorkDt%></td>
<td valign="top" align="center" width="65">Initials =
<%=Initials%></td>
<td valign="top" align="center" width="66">EstHrs = <%=EstHrs%></td>
<%hrAccum = hrAccum + Hours%>
<td valign="top" width="22">Hours = <%=Hours%></td>
<%HrDiff = EstHrs - Hours%>
<td valign="top" align="center" width="66"><b>HrDiff = <%=HrDiff%></b></td>

<%Details = replace(Details, "&quot;", "'")%>
<td valign="top" width="300">Details = <%=Details%></td>
<%if Billed <> "" then
if Billed = 1 then%>
<td valign="top" align="center" width="34">Y</td>
<%else%>
<td valign="top" align="center" width="12"><B>ELSE CONDITION
EXECUTED</B> N</td>
<%end if%>
<%else%>
<td valign="top" align="center" width="12">N</td>
<%end if%>
</tr>
--------------------

Also, just for the hell of it, put Option Explicit in your page if it's not
already there.

Ray at work

"Rahul Chatterjee" <an*******@devdex.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
In the view source I donot see the values for the details. That variable
value is entire absent.
Also the code section I had posted earlier was not posted in entirity.
The movenext and loop variables were missing (but the code in the data
is properly formed and without syntax errors)

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #7

P: n/a
Tried all that. If I reorganize the assignment it displays the values
but since the page has 2 entry points the sql queries to display the
data are different (even though both are simple select * statements). I
am just extracting the similar data from both results and displaying on
screen. I need to know why this is happening

Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #8

P: n/a
What does this do? With the code you provided, there is no reason that this
shouldn't work if your variables have values. Do you have an on error
resume next? If so, get rid of that and see if you're having issues with
nulls or an EOF that you don't expect.
------------------------

if not rsDetails.eof then
rsDetails.movefirst
prevProjectID = rsDetails("ProjectID")
do while not rsDetails.eof

ProjectID = rsDetails("ProjectID")
WorkDt = rsDetails("WorkDt")
EstHrs = cint(rsDetails("EstHrs"))
Hours = rsDetails("Hours")
Details = rsDetails("Details")
Initials = rsDetails("Initials")
Billed = rsDetails("Billed")

RESPONSE.WRITE "<TR><TD COLSPAN=""7"">" & ProjectID & "</TD></TR>"
if prevProjectID = ProjectID then%>
<tr>
<td valign="top" align="center" width="114"><%=ProjectID%></td>
<td valign="top" width="26"><%=WorkDt%></td>
<td valign="top" align="center" width="65"><%=Initials%></td>
<td valign="top" align="center" width="66"><%=EstHrs%></td>
<%hrAccum = hrAccum + Hours%>
<td valign="top" width="22"><%=Hours%></td>
<%HrDiff = EstHrs - Hours%>
<td valign="top" align="center" width="66"><b><%=HrDiff%></b></td>

<%Details = replace(Details, "&quot;", "'")%>
<td valign="top" width="300"><%=Details%></td>
<%if Billed <> "" then
if Billed = 1 then%>
<td valign="top" align="center" width="34">Y</td>
<%else%>
<td valign="top" align="center" width="12">N</td>
<%end if%>
<%else%>
<td valign="top" align="center" width="12">N</td>
<%end if%>
</tr>
------------------------

Ray at work







"Rahul Chatterjee" <an*******@devdex.com> wrote in message
news:O9*************@tk2msftngp13.phx.gbl...
Tried all that. If I reorganize the assignment it displays the values
but since the page has 2 entry points the sql queries to display the
data are different (even though both are simple select * statements). I
am just extracting the similar data from both results and displaying on
screen. I need to know why this is happening

Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #9

P: n/a
Post the entire page

I bet that you have a problem, somewhere that you aren't showing.
"Rahul Chatterjee" <an*******@devdex.com> wrote in message
news:O9*************@tk2msftngp13.phx.gbl...
Tried all that. If I reorganize the assignment it displays the values
but since the page has 2 entry points the sql queries to display the
data are different (even though both are simple select * statements). I
am just extracting the similar data from both results and displaying on
screen. I need to know why this is happening

Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #10

P: n/a
You don't mention which database is in use SQL server or Access - I suspect
the former

Having just ported a project across from Access to Sql Server (MSDE
actually), I have to say how suprised I was at the way recordset variables
would just disappear, or not be available shortly after having opened a
recordset.when using SQL server compared to Access/Jet

This article indicates the problem
http://www.aspfaq.com/show.asp?id=2188
but I 've also noticed it with date fields

my experience indicate that also the fields must be stored in to variables
in the exact order in which they were called in the select part of the sql -
of course very difficult when a * appears in the Select

You say your SQL is similar in both cases but not the same so I would think
almost certainly you need to store those vars in a different order for each
SQL

Access seesm to be much more forgiving ( by design?) in this respect, you
could open a record set at the top of a page and the recordset variables
would still be avaible by the time you got to the bottom ( except memo
fields on earlier version of MDAC as I recall) - (leaving a recordset open
that long is I, accept bad practice)

It does seem to be quite a large bug/feature of SQL server / MDAC - surely
its not by design ?

Maybe this is why GetRows gets pushed so highly round here and on the
various boards - yet to try it myself

just my 2p worth

"Rahul Chatterjee" <ra***@benesysinc.com> wrote in message
news:#T**************@TK2MSFTNGP11.phx.gbl...
Hello All

I have an asp page in which I am performing the following

1. Querying a database view
2. Returning rows in to a recordset.
3. Looping thru the recordset and printing the data
4. Before displaying the data I am assigning the values from the recordset
into variables
5. There are 2 entry points to this page both of which would run similar
queries and return similar results

My problem is that for a certain sequence of variable assignments, my data
is not displaying on the screen (even though when i do a response.write I
see that the variable actually has a value in it). In order to fix it I
rearranged the sequence of assignments but since I have two entry points to the page, it didnot display the data for the other entry point

Can anyone help with a suggestion/solution

Thank you

Jul 19 '05 #11

P: n/a
only me wrote:
You don't mention which database is in use SQL server or Access - I
suspect the former

Having just ported a project across from Access to Sql Server (MSDE
actually), I have to say how suprised I was at the way recordset
variables would just disappear, or not be available shortly after
having opened a recordset.when using SQL server compared to Access/Jet

I have NEVER encountered this problem. Even before I learned to start using
GetRows. Of course, I rarely use Text columns, but you seem to be saying
that it occurs for other dataypes as well ...

If you have a repro (SQL DDL, sample data, asp page) for this problem I
would love to play with it. I have never been able to reproduce this problem
when it has come up in these newsgroups.

Thanks,
Bob Barrows
Jul 19 '05 #12

P: n/a
this may be a recordset cursor issue
i think it's because you're retrieving the ProjectID twice.
that won't work with certain recordset cursors.
it leads to exactly the error you're describing

Forward Only(0) - Means you can only move forwards through the recordset.
Keyset(1) - allows you to move forwards and backwards through the recordset.
It also allows you see changes to the recordset as the records are
identified by keys. As such it is the least efficient of the CursorTypes and
shouldn't really be used.
Dynamic(2) - allows you to move forwards or backwards through the recordset.
Any changes to the recordset will also be visible.
Static(3) - allows you move forwards or backwards through the recordset.
However, this cursortype takes a static snapshot of the records at the time
the recordset is created. So, any changes to the recordset will not be seen
until the recordset is recreated.

hope this helps,

Jason

"Ray at <%=sLocation%>" <ra*@ajf8jalskdfna.sefrhja7yasdf.com> wrote in
message news:uy**************@TK2MSFTNGP11.phx.gbl...
I'd like a copy too please. :]

Ray at home

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
only me wrote:
You don't mention which database is in use SQL server or Access - I
suspect the former

Having just ported a project across from Access to Sql Server (MSDE
actually), I have to say how suprised I was at the way recordset
variables would just disappear, or not be available shortly after
having opened a recordset.when using SQL server compared to Access/Jet

I have NEVER encountered this problem. Even before I learned to start

using
GetRows. Of course, I rarely use Text columns, but you seem to be saying
that it occurs for other dataypes as well ...

If you have a repro (SQL DDL, sample data, asp page) for this problem I
would love to play with it. I have never been able to reproduce this

problem
when it has come up in these newsgroups.

Thanks,
Bob Barrows


Jul 19 '05 #13

P: n/a
http://charon.co.uk/content.aspx?Cat...=4&ArticleID=6

sorry, forgot to credit source. that article also mentions some SQLserver
scenarios that may throw similar errors to yours

jason
"jason kennedy" <ja***@pinhut.com> wrote in message
news:uf**************@TK2MSFTNGP11.phx.gbl...
this may be a recordset cursor issue
i think it's because you're retrieving the ProjectID twice.
that won't work with certain recordset cursors.
it leads to exactly the error you're describing

Forward Only(0) - Means you can only move forwards through the recordset.
Keyset(1) - allows you to move forwards and backwards through the recordset. It also allows you see changes to the recordset as the records are
identified by keys. As such it is the least efficient of the CursorTypes and shouldn't really be used.
Dynamic(2) - allows you to move forwards or backwards through the recordset. Any changes to the recordset will also be visible.
Static(3) - allows you move forwards or backwards through the recordset.
However, this cursortype takes a static snapshot of the records at the time the recordset is created. So, any changes to the recordset will not be seen until the recordset is recreated.

hope this helps,

Jason

"Ray at <%=sLocation%>" <ra*@ajf8jalskdfna.sefrhja7yasdf.com> wrote in
message news:uy**************@TK2MSFTNGP11.phx.gbl...
I'd like a copy too please. :]

Ray at home

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
only me wrote:
> You don't mention which database is in use SQL server or Access - I
> suspect the former
>
> Having just ported a project across from Access to Sql Server (MSDE
> actually), I have to say how suprised I was at the way recordset
> variables would just disappear, or not be available shortly after
> having opened a recordset.when using SQL server compared to Access/Jet >
I have NEVER encountered this problem. Even before I learned to start

using
GetRows. Of course, I rarely use Text columns, but you seem to be saying that it occurs for other dataypes as well ...

If you have a repro (SQL DDL, sample data, asp page) for this problem I would love to play with it. I have never been able to reproduce this

problem
when it has come up in these newsgroups.

Thanks,
Bob Barrows



Jul 19 '05 #14

P: n/a
Would like to be able to assist with a sample guys, but this is quite a big
project and it would be a heck of a lot of work to strip it down to a basic
reproducible sample

But it IS a real problem (for me anyway), the biggest pain is the fact that
there is no error generated.
I have only suffered from "(a) not show up at all, (b) only show up the
first time they're called," (http://www.aspfaq.com/show.asp?id=2188)

The problem is definately compounded by the use of the * in the select - so
even if the table has only 3 fields its still better to list them
individually in the select, although that still won't be enough in the case
of memo fields ( not sure what the SQL upsizer converted those to at the
moment)

The ASPFAQ article doesn't indicate its limited to just one database type -
but our code has been running for about 2 years on Access without problem
( with rather to much use of the * in SELECT's it has to be said).
Have converted it to MSDE over the last 3 weeks, and had numerous instances
of fields not being picked up.
Using lastest MDAC - 2.8 I think

And yes I have seen it with what was an Access date/Time field -
rs("FullMemberUntil") in sample #2

Also as I said the order of storing the recordset variables is important -
seems it must follow the left to right order of how it would appear in
Access Table display

I think Rahul may need to have 2 differnet set of recordset to var
assignment statments to match each of his 2 SQL statements
samples
I have refered to the field types by their Access names, don't have access
to what the SQL upsizer converted them to at the moment

* #1 Despite specifically calling out all the fields used, had to resort to
For/Next to get ALL vars
* text_n ( Access memo fields) head_n and image_n (Access text fields)
*
dim fieldlist
fieldlist =
"PageTitle,EditorType,head_1,head_2,head_3,head_4, head_5,image_1,image_2,ima
ge_3,image_4,image_5,text_1,text_2,text_3,text_4,t ext_5"
sql = "SELECT " & fieldlist & " FROM [pages] WHERE CompanyID = " & CompanyID
& " AND PageNo= " & PageNo
set rs_pages = Conn.execute(sql)
if rs_pages.EOF then ' there is no page in database, so create an empty one
sharpish, and re enter at the top of the page
response.redirect "CreateBlankPage.asp?CompanyID=" & CompanyID & "&pageno="
& pageno
end if

for i = 1 to 5
textblock(i) = trim(rs_pages("text_" & i ) & " ")
headblock(i) = trim(rs_pages("head_" & i ) & " ")
imgcapblock(i) = trim(rs_pages("image_" & i ) & " ")
next
pagetitle = rs_pages("PageTitle")

* #2
* This line "if FullMemberUntil >= Now then" used to be "if
rs("FullMemberUntil") >= Now" - but had to be converted to what you see
below to work in MSDE
* "FullMemberUntil" is a Access dateTime field

sql = "SELECT Company.*, Locality.*, Countries.* "
sql = sql & "FROM Countries INNER JOIN (Locality INNER JOIN Company ON
Locality.LocalityID = Company.LocalityID) ON Countries.CountryID =
Locality.CountryID "
sql = sql & " WHERE CompanyID=" & CompanyID

Set rs = conn.Execute(sql)

' do not change the order of these statements
comments = trim(rs("comments") & "") #### a meno field from
company table
GMcustomerID = rs("GMcustomerID") #### a number field from company
FullMemberUntil = rs("FullMemberUntil") #### a date/time field from
company
county = rs("county") #### a text
field from Locality
region = rs("region") #### a text
field from Locality
countryname = rs("countryname") #### a text field from
Countries
' do not change the order of these statements
if FullMemberUntil >= Now then
IsFullMember = True
else
IsFullMember = false
end if
project : www.index.guestmaster.com

"Ray at <%=sLocation%>" <ra*@ajf8jalskdfna.sefrhja7yasdf.com> wrote in
message news:uy**************@TK2MSFTNGP11.phx.gbl...
I'd like a copy too please. :]

Ray at home

"Bob Barrows" <re*******@yahoo.com> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
only me wrote:
You don't mention which database is in use SQL server or Access - I
suspect the former

Having just ported a project across from Access to Sql Server (MSDE
actually), I have to say how suprised I was at the way recordset
variables would just disappear, or not be available shortly after
having opened a recordset.when using SQL server compared to Access/Jet

I have NEVER encountered this problem. Even before I learned to start

using
GetRows. Of course, I rarely use Text columns, but you seem to be saying
that it occurs for other dataypes as well ...

If you have a repro (SQL DDL, sample data, asp page) for this problem I
would love to play with it. I have never been able to reproduce this

problem
when it has come up in these newsgroups.

Thanks,
Bob Barrows


Jul 19 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.