|
-
Mar 23rd, 2002, 06:49 PM
#1
Thread Starter
Junior Member
"invalid use of null" error. Makes no sense
If rstTable.Fields(2) = Null Then
strDescription = " "
Else
strDescription = rstTable.Fields(2)
'"Invalid use of null" error occurs right here. How can this be?
End If
-
Mar 23rd, 2002, 06:51 PM
#2
Frenzied Member
Try replacing Null with vbNullString.
You just proved that sig advertisements work.
-
Mar 25th, 2002, 11:48 AM
#3
Addicted Member
replace
If rstTable.Fields(2) = Null Then
with
if isnull(rstTable.Fields(2) then
and
strDescription = rstTable.Fields(2)
with
strDescription = rstTable.Fields(2) & ""
-
Mar 25th, 2002, 11:53 AM
#4
Hyperactive Member
I had a problem like this also. If you are dealing with SQL
the definition for Null does not work with VB's Definition.
If none of the previous suggestions work declare a Variable
of Type Varient. Put the database value in the variable and
then do your IF statement. That should do it.
-
Mar 25th, 2002, 12:03 PM
#5
Use the IsNull command
You can use:
If blahblah = Null
VB Code:
Use If IsNull(blahblah) = true then
'you got your null
else
'value is correct
end if
-
Mar 25th, 2002, 12:04 PM
#6
Sorry...
I meant:
"You can't use:"
-
Mar 25th, 2002, 05:09 PM
#7
That doesn't always work.
In ASP (VBScript), that won't work. Believe me, I've hit this wall before.
Try This:
VB Code:
If Len(rstTable.Fields(2).Value & "") = 0 Then
strDescription = ""
Else
strDescription = rstTable.Fields(2).Value
End If
-
Mar 25th, 2002, 07:02 PM
#8
Need-a-life Member
Just:
VB Code:
strDescription = "" & rstTable.Fields(2)
No care about if it's null or not.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
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
|