Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NULLS return Type Mismatch error. Why?

0 views
Skip to first unread message

King Wilder

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to

I've written a VB 6.0 component that retrieves records from SQL Server
7.0. Occasionally any particular column of a record might be NULL and
when I try to set a variable to that item I get a "Type Mismatch" error.


I can continue to retrieve other records if I include "On Error Resume
Next", but is this normal or am I doing something wrong?

Any help will be appreciated.

Thanks,

King Wilder
ki...@gizmobeach.com


CT

unread,
Jul 21, 2000, 3:00:00 AM7/21/00
to
King,

The only variable that can hold a NULL value is a varibale of type Variant.
You could check to see if the field contains a NULL value before you assign
it to a variable. If Not IsNull(rs.Fields"Field".Value) Then...)

--
Regards

Carsten Thomsen
MVP VB
MCSE/MCSD/VB Programmer & Analyst

PLEASE post ALL replies to the newsgroup(s) so we can all benefit from the
discussion!

"King Wilder" <ki...@gizmobeach.com> wrote in message
news:38F675F48B36D4118E4...@cpmsftmsgv21.microsoft.com...

Nathan Smith

unread,
Jul 31, 2000, 3:00:00 AM7/31/00
to

one "quick" way to take care of this is to do the following:

dim intKey as integer

....

while not rs.eof
intKey=iif(isnull(rs("pk_id")),<whatever indicates a bad value,
0?>,rs("pk_id"))
rs.movenext
wend

this will put whatever you want as a default value into the variable if
the field you're looking for is null.

--
Nathan Smith
602.502.3606
toomne...@aol.com

0 new messages