Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-01-2004, 01:51 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
null items in a record set

how do i handle a null item in a record set? for example:
Code:
while(rs.next()){
  int i = rs.getInt("FIELD_THAT_IS_NULL");
}
i keep getting sql exceptions when i try to use rs.getInt on a field that is null.
__________________
Mike
sde is offline   Reply With Quote
Old 09-01-2004, 02:07 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
ok, well a work around is to put that code in a try/catch block .. but isn't there a better way to test if a field of a recordset is valid?
__________________
Mike
sde is offline   Reply With Quote
Old 09-01-2004, 04:05 PM   #3 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,161
Belisarius is on a distinguished road
According to the documentation, if the field is null, the value returned is 0. So something wacky is going on there.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 09-01-2004, 04:08 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
wacky was me. it returns 0, i thought i had isolated it to that one line of code, but it was another field that i was naming wrong.
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hacking your Linksys WRT54G sde Linux / BSD / OS X 18 04-20-2005 03:37 PM
Need help with C++ ewic Standard C, C++ 7 10-01-2004 04:24 AM
OpenGL.dll Mr.Anderson Platform/API C++ 3 08-13-2004 10:07 AM
what language is this? sde All Other Coding Languages 10 05-25-2004 03:57 PM


All times are GMT -8. The time now is 11:37 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting