473,320 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

problem with conditional response.write

Hi there

I need to be able to print on screen when I check if a value within a db

<td>
<% if ((Recordset1.Fields.Item("profile1").Value) <>
"") then response.Write"Pro1<br>" &
Recordset1.Fields.Item("profile1").Value%>

</td>

I am checking if profile1 contains any text if not don't print anything. If
yes then print the heading and the contents .
Now the problem is that I cannot seem to check the value and print the same
value.
If I check profile2 instead of profile1 (which contains a value) then
profile1 is printed.
At the moment only Pro1 is written to the screen but the contents of
profile1 is not, eventhough profile1 is not empty.

What could be wrong ??

Thanks
Mar 20 '06 #1
17 1752
For now I would start by writing :
Response.Write Recordset1.Fields.Item("Profile1").value=""
to make sure this is not an empty string.

If not it could be null or a string that contains white spaces (especially
if the DB field uses CHAR instead of VARCHAR)...

--
Patrice

"raj chahal" <in**@digitise.info> a écrit dans le message de news:
%2****************@TK2MSFTNGP14.phx.gbl...
Hi there

I need to be able to print on screen when I check if a value within a db

<td>
<% if ((Recordset1.Fields.Item("profile1").Value) <>
"") then response.Write"Pro1<br>" &
Recordset1.Fields.Item("profile1").Value%>

</td>

I am checking if profile1 contains any text if not don't print anything.
If
yes then print the heading and the contents .
Now the problem is that I cannot seem to check the value and print the
same
value.
If I check profile2 instead of profile1 (which contains a value) then
profile1 is printed.
At the moment only Pro1 is written to the screen but the contents of
profile1 is not, eventhough profile1 is not empty.

What could be wrong ??

Thanks

Mar 20 '06 #2
Hi there are no emty strings..
Also the text 'Pro1' is written to screen meaning that part of it executes
but not the Recordset1.Fields.Item("profile1").Value bit in its current
surroundings..

"raj chahal" <in**@digitise.info> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi there

I need to be able to print on screen when I check if a value within a db

<td>
<% if ((Recordset1.Fields.Item("profile1").Value) <>
"") then response.Write"Pro1<br>" &
Recordset1.Fields.Item("profile1").Value%>

</td>

I am checking if profile1 contains any text if not don't print anything. If yes then print the heading and the contents .
Now the problem is that I cannot seem to check the value and print the same value.
If I check profile2 instead of profile1 (which contains a value) then
profile1 is printed.
At the moment only Pro1 is written to the screen but the contents of
profile1 is not, eventhough profile1 is not empty.

What could be wrong ??

Thanks

Mar 20 '06 #3
Not sure if this is a response to my suggestion.

What I meant is that if profile1 holds " " it will print Pro1 (as this
is not "") but you won't see anything visible. Similarly if the value is
null and if I remember well my ASP days, it will print Pro1 (as this is not
"") but you won't see anything either.

I would really double check. If it still fails print those values and report
them to us :
Value<>"" ' It would definitely allows to find out if the value
is an empty string or not
IsNull(Value) ' It would allow to find is this is NULL
Len(Value) ' It would allow to find if it contains non visible
characters

--
Patrice

"raj chahal" <in**@digitise.info> a écrit dans le message de news:
%2******************@TK2MSFTNGP12.phx.gbl...
Hi there are no emty strings..
Also the text 'Pro1' is written to screen meaning that part of it executes
but not the Recordset1.Fields.Item("profile1").Value bit in its current
surroundings..

"raj chahal" <in**@digitise.info> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi there

I need to be able to print on screen when I check if a value within a db

<td>
<% if ((Recordset1.Fields.Item("profile1").Value)
<>
"") then response.Write"Pro1<br>" &
Recordset1.Fields.Item("profile1").Value%>

</td>

I am checking if profile1 contains any text if not don't print anything.

If
yes then print the heading and the contents .
Now the problem is that I cannot seem to check the value and print the

same
value.
If I check profile2 instead of profile1 (which contains a value) then
profile1 is printed.
At the moment only Pro1 is written to the screen but the contents of
profile1 is not, eventhough profile1 is not empty.

What could be wrong ??

Thanks


Mar 20 '06 #4
Perhaps you have a NULL value. Try this.

<%
'''append an empty string to deal with possibility of null value
Dim sPro1
sPro1 = Recordset1.Fields.Item("profile1").Value & ""
If sPro1 <> "" Then Response.Write "Pro1<br>" & sPro1
%>

Ray at work
"raj chahal" <in**@digitise.info> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi there

I need to be able to print on screen when I check if a value within a db

<td>
<% if ((Recordset1.Fields.Item("profile1").Value) <>
"") then response.Write"Pro1<br>" &
Recordset1.Fields.Item("profile1").Value%>

</td>

I am checking if profile1 contains any text if not don't print anything.
If
yes then print the heading and the contents .
Now the problem is that I cannot seem to check the value and print the
same
value.
If I check profile2 instead of profile1 (which contains a value) then
profile1 is printed.
At the moment only Pro1 is written to the screen but the contents of
profile1 is not, eventhough profile1 is not empty.

What could be wrong ??

Thanks

Mar 20 '06 #5
Just in case you are unframiliar with NULL....

a Null value in a data field can appear as an empty string ("")....but it is
NOT an empty string. It is a value and it behaves like a value.

So, if a field contains a NULL value, then it may appear as though it is
empty, but technically, it is not empty. Perhaps you just want to add to
your conditional test:

if ( (..... <> "") AND (..... <> "Null") ) then .....

Just a thought.

"raj chahal" wrote:
Hi there are no emty strings..
Also the text 'Pro1' is written to screen meaning that part of it executes
but not the Recordset1.Fields.Item("profile1").Value bit in its current
surroundings..

"raj chahal" <in**@digitise.info> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi there

I need to be able to print on screen when I check if a value within a db

<td>
<% if ((Recordset1.Fields.Item("profile1").Value) <>
"") then response.Write"Pro1<br>" &
Recordset1.Fields.Item("profile1").Value%>

</td>

I am checking if profile1 contains any text if not don't print anything.

If
yes then print the heading and the contents .
Now the problem is that I cannot seem to check the value and print the

same
value.
If I check profile2 instead of profile1 (which contains a value) then
profile1 is printed.
At the moment only Pro1 is written to the screen but the contents of
profile1 is not, eventhough profile1 is not empty.

What could be wrong ??

Thanks


Mar 20 '06 #6

pulaki wrote:
Just in case you are unframiliar with NULL....

a Null value in a data field can appear as an empty string ("")....but it is
NOT an empty string. It is a value and it behaves like a value.

So, if a field contains a NULL value, then it may appear as though it is
empty, but technically, it is not empty. Perhaps you just want to add to
your conditional test:

if ( (..... <> "") AND (..... <> "Null") ) then .....

Just a thought.


Shouldn't that be

If ( (..... <> "") And ( Not IsNull(.......)) ) Then ..... ?

<>"Null" means is not equal to a string with the value "Null" - as
opposed to a null value. doesn't it? Or am I confusing database nulls
and vbscript nulls?

--
Mike Brind

Mar 20 '06 #7
Patrice wrote:
if ((Recordset1.Fields.Item("profile1").Value) <>
"") then response.Write"Pro1<br>" &
Recordset1.Fields.Item("profile1").Value


...Similarly if the value is null and if I remember well
my ASP days, it will print Pro1 (as this is not "") but
you won't see anything either.


Afraid you don't remember your VBScript correctly, Patrice. If either
argument is Null, the inequality returns Null:
http://msdn.microsoft.com/library/en...486d5f1e30.asp
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Mar 20 '06 #8

Mike Brind wrote:
pulaki wrote:
Just in case you are unframiliar with NULL....

a Null value in a data field can appear as an empty string ("")....but it is
NOT an empty string. It is a value and it behaves like a value.

So, if a field contains a NULL value, then it may appear as though it is
empty, but technically, it is not empty. Perhaps you just want to add to
your conditional test:

if ( (..... <> "") AND (..... <> "Null") ) then .....

Just a thought.

Shouldn't that be

If ( (..... <> "") And ( Not IsNull(.......)) ) Then ..... ?


Correction:

If ( (..... <> "") And (IsNull(.......)=False) ) Then ..... ?

<>"Null" means is not equal to a string with the value "Null" - as
opposed to a null value. doesn't it? Or am I confusing database nulls
and vbscript nulls?

--
Mike Brind


Mar 21 '06 #9
I wonder why I didn't thought VBScript would be clever enough to be
consistent with the usual NULL behavior ;-)

So, it would finally likely left us with non visible characters in profile1
(perhaps because of the use of CHAR). Hopefully the original poster will pop
up once checked...

--
Patrice

"Dave Anderson" <GT**********@spammotel.com> a écrit dans le message de
news: eH**************@TK2MSFTNGP14.phx.gbl...
Patrice wrote:
if ((Recordset1.Fields.Item("profile1").Value) <>
"") then response.Write"Pro1<br>" &
Recordset1.Fields.Item("profile1").Value


...Similarly if the value is null and if I remember well
my ASP days, it will print Pro1 (as this is not "") but
you won't see anything either.


Afraid you don't remember your VBScript correctly, Patrice. If either
argument is Null, the inequality returns Null:
http://msdn.microsoft.com/library/en...486d5f1e30.asp
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.
Use of this email address implies consent to these terms. Please do not
contact me directly or ask me to contact you directly for assistance. If
your question is worth asking, it's worth posting.

Mar 21 '06 #10
>> If ( (..... <> "") And ( Not IsNull(.......)) ) Then ..... ?
Correction:
If ( (..... <> "") And (IsNull(.......)=False) ) Then ..... ?


Why the correction?

Mar 21 '06 #11
Hi there again..

Thanks for your help.. I have now discovered something weird that explains
the problem below..
When I check froa a value or print a value from recordset the value is
emptied ! This is why I have the problem.

I tested with the below code :

1 <%
2 response.Write "profile1 - " &
(Recordset1.Fields.Item("profile1").Value) & "-<br> "

3 ' if ((Recordset1.Fields.Item("profile1").Value) <> null) then
4 response.Write "Pro1 " & (Recordset1.Fields.Item("profile1").Value)
5 ' End IF
6 %>

When I execute the above the response is :

profile1 - Photoshop and guitar playing-
Pro1

Therefore the value of (Recordset1.Fields.Item("profile1").Value) is now
somehow empty in line 4 !

When I comment line 2 the response is :

Pro1 Photoshop and guitar playing

So now (Recordset1.Fields.Item("profile1").Value) in line 4 prints !

The value of (Recordset1.Fields.Item("profile1").Value) is also emptied on
any checking for null.
I know line 3 may be incorrect for the moment but this is commented for this
test.

Any ideas on this pls ?
Thanks again
"raj chahal" <in**@digitise.info> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi there

I need to be able to print on screen when I check if a value within a db

<td>
<% if ((Recordset1.Fields.Item("profile1").Value) <>
"") then response.Write"Pro1<br>" &
Recordset1.Fields.Item("profile1").Value%>

</td>

I am checking if profile1 contains any text if not don't print anything. If yes then print the heading and the contents .
Now the problem is that I cannot seem to check the value and print the same value.
If I check profile2 instead of profile1 (which contains a value) then
profile1 is printed.
At the moment only Pro1 is written to the screen but the contents of
profile1 is not, eventhough profile1 is not empty.

What could be wrong ??

Thanks

Mar 21 '06 #12

Anthony Jones wrote:
If ( (..... <> "") And ( Not IsNull(.......)) ) Then ..... ?

Correction:
If ( (..... <> "") And (IsNull(.......)=False) ) Then ..... ?


Why the correction?


Is the first one valid?

Mar 21 '06 #13
Mike Brind wrote:
Anthony Jones wrote:
If ( (..... <> "") And ( Not IsNull(.......)) ) Then ..... ?

Correction:
If ( (..... <> "") And (IsNull(.......)=False) ) Then ..... ?


Why the correction?


Is the first one valid?


Why go through all this rigmarole? A simple

If len(yourvariable)>0 then
'it's got a value
else
'it's either null or an empty string
end if

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Mar 21 '06 #14
Never saw this. You may want also to use "view source" in case you would
have some kind of html markup inside the value that causes a problem in
rendering and make the value appears to be empty when it would be just not
rendered.

The first test I can think off would be something like :
Response.Write Now() & "<br>" ' To make sure the test is current
Response.Write Recordset1.Fields.Item("profile1").Value="Photosho p and
guitar playing" & "<br>"
Response.Write Recordset1.Fields.Item("profile1").Value & '"<br>"
Response.Write Recordset1.Fields.Item("profile1").Value="Photosho p and
guitar playing" & "<br>"
Response.Write Recordset1.Fields.Item("profile1").Value & "<br>"

To make sure if printing the value is really destructive. I suppose
Recordset1 is a usual ADOB recordset ?

Good luck.
--
Patrice

"raj chahal" <in**@digitise.info> a écrit dans le message de news:
uY*************@TK2MSFTNGP12.phx.gbl...
Hi there again..

Thanks for your help.. I have now discovered something weird that explains
the problem below..
When I check froa a value or print a value from recordset the value is
emptied ! This is why I have the problem.

I tested with the below code :

1 <%
2 response.Write "profile1 - " &
(Recordset1.Fields.Item("profile1").Value) & "-<br> "

3 ' if ((Recordset1.Fields.Item("profile1").Value) <> null) then
4 response.Write "Pro1 " &
(Recordset1.Fields.Item("profile1").Value)
5 ' End IF
6 %>

When I execute the above the response is :

profile1 - Photoshop and guitar playing-
Pro1

Therefore the value of (Recordset1.Fields.Item("profile1").Value) is now
somehow empty in line 4 !

When I comment line 2 the response is :

Pro1 Photoshop and guitar playing

So now (Recordset1.Fields.Item("profile1").Value) in line 4 prints !

The value of (Recordset1.Fields.Item("profile1").Value) is also emptied on
any checking for null.
I know line 3 may be incorrect for the moment but this is commented for
this
test.

Any ideas on this pls ?
Thanks again
"raj chahal" <in**@digitise.info> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi there

I need to be able to print on screen when I check if a value within a db

<td>
<% if ((Recordset1.Fields.Item("profile1").Value)
<>
"") then response.Write"Pro1<br>" &
Recordset1.Fields.Item("profile1").Value%>

</td>

I am checking if profile1 contains any text if not don't print anything.

If
yes then print the heading and the contents .
Now the problem is that I cannot seem to check the value and print the

same
value.
If I check profile2 instead of profile1 (which contains a value) then
profile1 is printed.
At the moment only Pro1 is written to the screen but the contents of
profile1 is not, eventhough profile1 is not empty.

What could be wrong ??

Thanks


Mar 21 '06 #15

"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11*********************@z34g2000cwc.googlegro ups.com...

Anthony Jones wrote:
> If ( (..... <> "") And ( Not IsNull(.......)) ) Then ..... ?

Correction:
If ( (..... <> "") And (IsNull(.......)=False) ) Then ..... ?


Why the correction?


Is the first one valid?


I don't see anything wrong with it. IsNull returns a boolean which is
flipped then And'ed with the expression prior to it which also returns a
boolean.

Still I prefer Bob's solution. :)

Anthony.
Mar 21 '06 #16

Anthony Jones wrote:
"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11*********************@z34g2000cwc.googlegro ups.com...

Anthony Jones wrote:
>> If ( (..... <> "") And ( Not IsNull(.......)) ) Then ..... ?

>Correction:
>If ( (..... <> "") And (IsNull(.......)=False) ) Then ..... ?

Why the correction?


Is the first one valid?


I don't see anything wrong with it. IsNull returns a boolean which is
flipped then And'ed with the expression prior to it which also returns a
boolean.

Still I prefer Bob's solution. :)

Anthony.


So do I. It's the one I use - I don't use IsNull very often at all in
VBScript. I generally use AND [value] IS NOT NULL in my SQL to prevent
nulls ever getting to the recordset....

--
Mike Brind

Mar 21 '06 #17
Patrice wrote:
I wonder why I didn't thought VBScript would be clever enough
to be consistent with the usual NULL behavior ;-)


One of the many comforts of JScript is its Boolean coercion. Since null and
empty string each coerce to false, this is sufficient in JScript:

if (Recordset1.Fields("profile1").Value) ...

Of course, this leads to one potential obstacle -- numeric zero is also
"false". Never hurts to know your data...

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Mar 21 '06 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Guy Hocking | last post by:
Hi there, I am having a few problems compiling a list box that is conditional on what is selected in another list box. What i need is a List box (lstArea) that displays one thing when the List...
10
by: Thomas | last post by:
Hi, Will this work in asp 3.0: If True Then <!-- #include file="test1.asp" --> Else <!-- #include file="test2.asp" --> End If
13
by: Gary | last post by:
I am trying to do a simple "less than" conditional statement, and hitting a brick wall if I use a database element with it. This DOES work: <% if Request.QueryString("PC") < 10 then...
3
by: Patrice | last post by:
Hi, I need to do multi-conditional statements like below, but this error is displayed : Expected 'End' /myFilepath, line x else response.write(arrCorpo(sparam,sdiv)) end if I don't...
42
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox...
12
by: Brad Baker | last post by:
I am trying to write a simple ASP.net/C# page which allows users to select some values and produce a report based on a SQL query. I have a self posting dropdown form which allows users to select...
102
by: hug | last post by:
www.webmaster, was suggested that this ng could be a better place.] I've updated my test server to handle if-modified-since. I've noticed that the (old copies I run of) IE and Netscape seem...
1
by: Yoni | last post by:
I created two projects, one web and one windows app. The Conditional code works ONLY for the windows app: #if (DEBUG) MessageBox.Show ("In Debug"); #else MessageBox.Show("Not Debug"); #endif ...
3
by: Jon L | last post by:
Hi, I'm hoping someone can help me with this problem. I'm not sure whether the problem lies with the software or with my understanding of the language. I'm using the Microsoft.XMLDOM object...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.