|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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
|
|
#3
|
|||
|
|||
|
NumberNine,
Thanks for replying I'll try the Len and see if it works any better Rich |
|
#4
|
||||
|
||||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Need some help with NULL fields in DB |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|