Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: if returns true but won't execute code


Message #1 by Spencer Saunders <spence@s...> on Sun, 15 Dec 2002 23:05:00 -0500
Hello all,

I am having a strange and stupid problem with some very simple code.

I am simply trying to see of there is anything in a requested field
from the DB and if there is then display it - if there isn't then
don't. Pretty normal stuff.

if I don't write any "if" statement then the field displays (if it
exists) but if I check to see if it exists (determined by the length of=20

it's contents) and it returns greater than 1 it won't display.

I don't get it. The same method has worked for several other fields on=20

the page but not this one.

Am I just losing my mind. Thanks, spence

CODE:

if trim(len(RS("show_copy"))) > 0 then
' THE NEXT TWO LINE ALWAYS DISPLAY IF characters in  show_copy > 0
response.write "true" & "<br>"
response.write "<strong>SHOW SUMMARY:</strong><br>"
'BUT THIS DOESN"T WANT TO DiSPLAY
response.write RS("show_copy")
end if
=00=00

Message #2 by "Ken Schaefer" <ken@a...> on Tue, 17 Dec 2002 11:12:36 +1100
What type of field is "show_copy"?

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Spencer Saunders" <spence@s...>
Subject: [access_asp] if returns true but won't execute code


Hello all,

I am having a strange and stupid problem with some very simple code.

I am simply trying to see of there is anything in a requested field 
from the DB and if there is then display it - if there isn't then 
don't. Pretty normal stuff.

if I don't write any "if" statement then the field displays (if it 
exists) but if I check to see if it exists (determined by the length of 
it's contents) and it returns greater than 1 it won't display.

I don't get it. The same method has worked for several other fields on 
the page but not this one.

Am I just losing my mind. Thanks, spence

CODE:

if trim(len(RS("show_copy"))) > 0 then
' THE NEXT TWO LINE ALWAYS DISPLAY IF characters in  show_copy > 0
response.write "true" & "<br>"
response.write "<strong>SHOW SUMMARY:</strong><br>"
'BUT THIS DOESN"T WANT TO DiSPLAY
response.write RS("show_copy")
end if


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #3 by Spencer Saunders <spence@s...> on Wed, 18 Dec 2002 23:27:58 -0500
It's a memo field

Spence
On Monday, December 16, 2002, at 07:12  PM, Ken Schaefer wrote:

> What type of field is "show_copy"?
>
> Cheers
> Ken
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> From: "Spencer Saunders" <spence@s...>
> Subject: [access_asp] if returns true but won't execute code
>
>
> Hello all,
>
> I am having a strange and stupid problem with some very simple code.
>
> I am simply trying to see of there is anything in a requested field
> from the DB and if there is then display it - if there isn't then
> don't. Pretty normal stuff.
>
> if I don't write any "if" statement then the field displays (if it
> exists) but if I check to see if it exists (determined by the length of
> it's contents) and it returns greater than 1 it won't display.
>
> I don't get it. The same method has worked for several other fields on
> the page but not this one.
>
> Am I just losing my mind. Thanks, spence
>
> CODE:
>
> if trim(len(RS("show_copy"))) > 0 then
> ' THE NEXT TWO LINE ALWAYS DISPLAY IF characters in  show_copy > 0
> response.write "true" & "<br>"
> response.write "<strong>SHOW SUMMARY:</strong><br>"
> 'BUT THIS DOESN"T WANT TO DiSPLAY
> response.write RS("show_copy")
> end if
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>

Message #4 by "Ken Schaefer" <ken@a...> on Thu, 19 Dec 2002 16:16:50 +1100
Memo fields always present problems :-) This is because Memo fields (and
Text fields in SQL Server) can be quite large (they are not stored in the
record's table row, only a pointer to the actual location is). ADO doesn't
always know how much data there is.

Things you can try:
a) try allocating the value of the memo field to a variable, then using the
variable throughout your code

b) make sure that the memo field is the last named field in your SELECT
statement:
SELECT ...all other fields here..., myMemoField FROM table

c) If none of that works, then you'll have to use .GetChunk to get the data
out of the database.

This KB article (under "more information"):
http://support.microsoft.com/default.aspx?scid=kb;EN-US;175239
explains some of the problems with dealing with Memo/Text fields

This KB article:
http://support.microsoft.com/default.aspx?scid=KB;en-us;q200124
explains what you need to do, and links to another article showing you how
to use .GetChunk and .AppendChunk

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Spencer Saunders" <spence@s...>
Subject: [access_asp] Re: if returns true but won't execute code


: It's a memo field
:
: Spence
: On Monday, December 16, 2002, at 07:12  PM, Ken Schaefer wrote:
:
: > What type of field is "show_copy"?
: >
: > Cheers
: > Ken
: >
: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: > From: "Spencer Saunders" <spence@s...>
: > Subject: [access_asp] if returns true but won't execute code
: >
: >
: > Hello all,
: >
: > I am having a strange and stupid problem with some very simple code.
: >
: > I am simply trying to see of there is anything in a requested field
: > from the DB and if there is then display it - if there isn't then
: > don't. Pretty normal stuff.
: >
: > if I don't write any "if" statement then the field displays (if it
: > exists) but if I check to see if it exists (determined by the length of
: > it's contents) and it returns greater than 1 it won't display.
: >
: > I don't get it. The same method has worked for several other fields on
: > the page but not this one.
: >
: > Am I just losing my mind. Thanks, spence
: >
: > CODE:
: >
: > if trim(len(RS("show_copy"))) > 0 then
: > ' THE NEXT TWO LINE ALWAYS DISPLAY IF characters in  show_copy > 0
: > response.write "true" & "<br>"
: > response.write "<strong>SHOW SUMMARY:</strong><br>"
: > 'BUT THIS DOESN"T WANT TO DiSPLAY
: > response.write RS("show_copy")
: > end if


  Return to Index