469,322 Members | 1,057 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,322 developers. It's quick & easy.

Null value breaking result set


I call a stored procedure via classic ASP (1.1). I loop through the results and print out items on a page. Pretty basic concept but what I'm finding is that if a row from the database comes back as null, the next row doesn't display even though it's not null and has data in it. See the code below:

Expand|Select|Wrap|Line Numbers
  1. details1Query = "EXECUTE storedprocedure"
  2. set details1RS = conn.Execute(details1Query)
  3. do while not details1RS.eof
  4.     Response.Write("value1: " & details1RS("value1") & "<br>")
  5.     Response.Write("value2: " & details1RS("value2") & "<br>")
  6.                 Response.Write("value3: " & details1RS("value3") & "<br>")
  7.     Response.Write("value3: " & details1RS("value4") & "<hr>")
  8. details1RS.MoveNext
  9. loop

value1 has text - it will print out fine
value2 is null - Nothing prints
value3 has text - nothing prints
value4 has text - it will print out fine

If I comment out value2 then value3 prints. Any ideas why this would be occuring? It appears that if a value is null then it breaks the next row underneath it. The stored procedure that it is calling joins multiple tables together. value2 and value3 are from different tables. Any information would be helpful.

Oct 28 '08 #1
2 2558
979 Expert 512MB
Hi ssouhrada,

Thats an odd one, have you got any error trapping on your page?

You should be able to fix this by checking for NULLS within your stored procedure. Take a look at the following example:

Expand|Select|Wrap|Line Numbers
  2. Name,
  3. ISNULL(Address, ' ') AS Address
  4. FROM PersonTable
The ISNULL function will return whatever you like (in this case a space) whenever it finds a null value.

Hope this helps,

Dr B
Oct 29 '08 #2

Thanks for responding. That ISNULL feature of stored procedures will come in handy. What I found that solved my issue was actually the order that the results were coming back via the stored procedure.

Stored Procedure: "storedprocedure"

Select value1, value2, value3, value4 from table

When looping through the results on the page if I were to access value3 first then value1 and value2 were no longer available. This is something that I had to learn the hard way. I don't believe it has anything to do with the value being null or not but just having the earlier results in the table no longer accessible. So what I will need to do is adjust the order of results in the stored procedure to build my page.

Oct 29 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by iStrain | last post: by
102 posts views Thread by junky_fellow | last post: by
99 posts views Thread by Mikhail Teterin | last post: by
9 posts views Thread by Steve Sargent | last post: by
64 posts views Thread by yossi.kreinin | last post: by
11 posts views Thread by CreativeMind | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.