|
-
Jul 17th, 2008, 08:47 AM
#1
Thread Starter
PowerPoster
[RESOLVED] If this were null, would ASP choke?
I have converted ASP code to .NET and my new program bombed on a null value. I was wondering if it's the first time ever that this value has been null or if ASP somehow got away with it when it was null in the past. The field in questin is oRS("usage_value"). Here is the ASP code:
Code:
<%If oRS("usage_value") > 0 Then%>
<A HREF="../../GoToThisPage.asp?val1=<%=val1%>&val2=<%=oRS("val2")%>&val3=<%=oRS("val3")%>&usage_value=<%=oRS("usage_value")%>" TARGET="HIST"><IMG SRC="../../images/view.gif" BORDER="0"></A>
<%Else%>
<B><FONT COLOR="red">!</FONT></B>
<%End If%>
I know what I can do to fix the problem but I will be changing a view which as far as I know has been in existence a long, long time. So I'd like to know if ASP would also have choke on this? (I will be rigging up some data to test it, but also wanted to hear if the forum would have anything to say).
Thanks...
-
Jul 17th, 2008, 09:38 AM
#2
Re: If this were null, would ASP choke?
It should give an error, "Invalid use of Null".
A simple fix (which will treat Null as 0, but not affect anything else) is to add this:
Code:
<%If CLng("0" & oRS("usage_value")) > 0 Then%>
-
Jul 17th, 2008, 10:52 AM
#3
Thread Starter
PowerPoster
Re: If this were null, would ASP choke?
I can't restore the data to the state it was in on Tuesday when the .net exception occured. Our data is weird because the production db's are backed up every morning but because of feeds we get from a wholesaler that then get processed, I couldn't recreate the scenario that resulted in the null value.
Anyway, this was returning the null:
Code:
(SELECT tableA_ik
FROM tableA
WHERE blah blah blah = blah blah blah
AND active_ind = 1)
AS tableA_ik
tableA_ik can never be null (it's a key so nulls aren't allowed) but this query is returning a null. This same query appears in another stored proc like this:
Code:
ISNULL((SELECT tableA_ik
FROM tableA
WHERE blah blah blah = blah blah blah
AND active_ind = 1) , 0)
AS tableA_ik
which safely return the 0 instead of the null. So I will modify the bad one similarly. It just troubles me this happened only when I introduced my migrated code. Bad timing, or what?
Thanks,
Marlene
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|