ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 5th, 2003, 01:04 PM
richh richh is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Phoenix, AZ
Posts: 11 richh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Need some help with NULL fields in DB

Hi all,

Well last time I needed some help I got it here so I decided to see if my luck would last for one more problem.. I have a DB and I need to determine if that field in my DB is empty. If it is then I need to return a different value to my page then if it wasn't empty..

Not sure if I'm doing this correct but I figured if I didn't try I would't get anywhere so here is what I have

Code:
   Do While Not oRS.EOF
   Response.Write"<tr><td>" & oRS("seminarLngName") & "</td>"
   Response.Write"<td>" & "</td>"
   If oRS("seminarMap") = "" Then
            Response.Write"<td>N/A</td></tr>"
   Else
            Response.Write"<td><a href=" & oRS("seminarMap") & ">Click Here</a></td></tr>"
   End If
   oRS.MoveNext
   LOOP


I keep getting an error saying that there is a 'Then' expected..

Please help..

Thanks in advance,

Rich

Reply With Quote
  #2  
Old March 5th, 2003, 04:07 PM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 6
Not sure why you're getting the error, Rich. Code looks fine to me.

What I usually do for checking nulls is to check the length of the string. If it's zero, I know it's null:

Code:
If Len(oRS("seminarMap")) > 0 Then
     'we've got something
Else
     'null
End If

Reply With Quote
  #3  
Old March 5th, 2003, 04:14 PM
richh richh is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Phoenix, AZ
Posts: 11 richh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
NumberNine,

Thanks for replying

I'll try the Len and see if it works any better

Rich

Reply With Quote
  #4  
Old March 6th, 2003, 08:08 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
For checking if a value from the database is empty - you need to check two things - null, or empty string.

so your If statement should look something like:

Code:
if isnull(varDBValue) or varDBValue = "" then
   'empty value
else
   ' field contains data
end if


note: isnull() is a builtin ASP function

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Need some help with NULL fields in DB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT