|
 |
access_asp thread: desperate! null detect just not working!!
Message #1 by jake williamson <jake.williamson@2...> on Fri, 6 Sep 2002 10:24:19 +0100
|
|
hello,
got a real simple null detection script in a web page that works on
other sites i've done, i just cant figure out why it's not working on
this one!
this is it:
<%
If productsResults.Fields.Item("THUMBNAIL") =3D null OR
productsResults.Fields.Item("THUMBNAIL") =3D "" THEN
Response.Write ""
Else
Response.Write "then write the image"
End If
%>=00
it looks at the THUMBNAIL column and if it is null or has no entry
nothing is written to the page. if it is though, it writes the image.
but it isn't working!! when i run the query in dw it shows null in the=20
results panel????
any thoughts??? it's real desperate, i neet ot get this site up today!
cheers,
jake
Message #2 by "Ken Schaefer" <ken@a...> on Sat, 7 Sep 2002 11:20:06 +1000
|
|
Nothing ever equals NULL - not even another NULL. This is by definition. If
you do this:
<%
If NULL = NULL then
Response.Write("It's Equal")
Else
Response.Write("It's not Equal")
End If
%>
you will always get the second line, never the first. You need to use the
IsNull() function in VBScript if you want to do it the way you are doing it:
Set objFieldThumbNail = productsResults.Fields.Item("THUMBNAIL")
<%
If IsNull(objFieldThumbNail.Value) or objFieldThumbNail.Value = "" then
Response.Write ""
Else
Response.Write "the image"
End If
%>
Or you can use the IIF() function inside your SQL query, which is probably a
more efficient way to do it.
The reason your code "worked" before is probably because you never had to
deal with NULLs before, you always had zero length strings.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "jake williamson" <jake.williamson@2...>
Subject: [access_asp] desperate! null detect just not working!!
hello,
got a real simple null detection script in a web page that works on
other sites i've done, i just cant figure out why it's not working on
this one!
this is it:
<%
If productsResults.Fields.Item("THUMBNAIL") = null OR
productsResults.Fields.Item("THUMBNAIL") = "" THEN
Response.Write ""
Else
Response.Write "then write the image"
End If
%>
it looks at the THUMBNAIL column and if it is null or has no entry
nothing is written to the page. if it is though, it writes the image.
but it isn't working!! when i run the query in dw it shows null in the
results panel????
any thoughts??? it's real desperate, i neet ot get this site up today!
cheers,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #3 by jake williamson <jake.williamson@2...> on Mon, 9 Sep 2002 10:50:24 +0100
|
|
hello ken,
again, saved the day! thanks for that, the code now works perfectly and
is uploading as we speak.
i've been trying to use the same piece of code again for a larger view
link that works on the product id which is a number. the code looks like:
<%
If IsNull(productsResults.Fields.Item("THUMBNAIL").Value) or
productsResults.Fields.Item("THUMBNAIL").Value = "" then
Response.Write ""
Else
Response.Write "<a href=""#""
onMouseDown=""javascript:NewWindow('product_detail.asp?prodid=" +
productsResults.Fields.Item("PRODID").Value +
"','productDetail','450','370','no')"">Full Spec</a>"
End If
%>
the weird thing is it throws up this error:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "<a href="#" onMouseD"]'
if i change the requested field to any other result on in the query (eg
the THUMBNAIL) it works fine! but obviously dont send the info onto the
detail page.....
it's almost as if i need to change the style of return, i.e. it's a
number. the weird thing is, i i use it as a regular link it works fine?
any ideas??
many, many thanks for your help,
jake
On Saturday, September 7, 2002, at 02:20 AM, Ken Schaefer wrote:
> Nothing ever equals NULL - not even another NULL. This is by
> definition. If
> you do this:
>
> <%
> If NULL = NULL then
> Response.Write("It's Equal")
> Else
> Response.Write("It's not Equal")
> End If
> %>
>
> you will always get the second line, never the first. You need to use
> the
> IsNull() function in VBScript if you want to do it the way you are
> doing it:
>
> Set objFieldThumbNail = productsResults.Fields.Item("THUMBNAIL")
>
> <%
> If IsNull(objFieldThumbNail.Value) or objFieldThumbNail.Value = "" then
> Response.Write ""
> Else
> Response.Write "the image"
> End If
> %>
>
> Or you can use the IIF() function inside your SQL query, which is
> probably a
> more efficient way to do it.
>
> The reason your code "worked" before is probably because you never had
> to
> deal with NULLs before, you always had zero length strings.
>
> Cheers
> Ken
Message #4 by "Ken Schaefer" <ken@a...> on Tue, 10 Sep 2002 11:36:02 +1000
|
|
Can I suggest not using + to concatenate strings. It is an overloaded
operater.
Use & instead.
Also, what is in the ProdID field for the record that is causing the error?
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "jake williamson" <jake.williamson@2...>
Subject: [access_asp] Re: desperate! null detect just not working!!
:
: hello ken,
:
: again, saved the day! thanks for that, the code now works perfectly and
: is uploading as we speak.
:
: i've been trying to use the same piece of code again for a larger view
: link that works on the product id which is a number. the code looks like:
:
: <%
: If IsNull(productsResults.Fields.Item("THUMBNAIL").Value) or
: productsResults.Fields.Item("THUMBNAIL").Value = "" then
: Response.Write ""
: Else
: Response.Write "<a href=""#""
: onMouseDown=""javascript:NewWindow('product_detail.asp?prodid=" +
: productsResults.Fields.Item("PRODID").Value +
: "','productDetail','450','370','no')"">Full Spec</a>"
: End If
: %>
:
: the weird thing is it throws up this error:
:
: Microsoft VBScript runtime (0x800A000D)
: Type mismatch: '[string: "<a href="#" onMouseD"]'
:
: if i change the requested field to any other result on in the query (eg
: the THUMBNAIL) it works fine! but obviously dont send the info onto the
: detail page.....
:
: it's almost as if i need to change the style of return, i.e. it's a
: number. the weird thing is, i i use it as a regular link it works fine?
:
: any ideas??
:
: many, many thanks for your help,
:
: jake
:
:
: On Saturday, September 7, 2002, at 02:20 AM, Ken Schaefer wrote:
:
: > Nothing ever equals NULL - not even another NULL. This is by
: > definition. If
: > you do this:
: >
: > <%
: > If NULL = NULL then
: > Response.Write("It's Equal")
: > Else
: > Response.Write("It's not Equal")
: > End If
: > %>
: >
: > you will always get the second line, never the first. You need to use
: > the
: > IsNull() function in VBScript if you want to do it the way you are
: > doing it:
: >
: > Set objFieldThumbNail = productsResults.Fields.Item("THUMBNAIL")
: >
: > <%
: > If IsNull(objFieldThumbNail.Value) or objFieldThumbNail.Value = "" then
: > Response.Write ""
: > Else
: > Response.Write "the image"
: > End If
: > %>
: >
: > Or you can use the IIF() function inside your SQL query, which is
: > probably a
: > more efficient way to do it.
: >
: > The reason your code "worked" before is probably because you never had
: > to
: > deal with NULLs before, you always had zero length strings.
: >
: > Cheers
: > Ken
:
:
|
|
 |