Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 4th, 2006, 02:16 AM
Friend of Wrox
Join Date: Apr 2004
Location: San Francisco, CA, USA.
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default Nullable Type Question

I have a variable defined as Nullable (Of Int32). But I can't seem to assign it a value of DBNull. Seems it can only take VBNull. How the heck am I supposed to use it with a database then? The following code breaks every time a null value comes out of the database:

dim myNullableInt as Nullable (of Int32)
myNullableInt = myDataReader("myPossiblyNullField")



  #2 (permalink)  
Old August 30th, 2007, 07:37 AM
Authorized User
Join Date: Aug 2007
Location: mumbai, maharashtra, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts

hi Aaron
this is Shakti, i work as Software Programmer.

Your query can be easily solved.
You dont have to define a nullable variable.
Just define a variable of ur required type, in this case integer.

the code goes like this (the code has been written in C#, u can transform it to VB)

int i;
if(myDataReader("myPossiblyNullField")==DBNULL.Val ue)
i=0;// whatever the value u want to pass for null database values.

hope u find it helpful.
reply ur comments.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about value class type saadli BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 4 December 3rd, 2008 10:15 PM
Nullable Datetime shivamnshah BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 April 26th, 2007 12:46 PM
Research Type Question nadee Oracle 0 March 18th, 2007 11:12 PM
Question about Nullable Types Aaron Edwards ASP.NET 2.0 Basics 5 December 10th, 2006 11:57 PM
Data Type Question dparsons ASP.NET 1.0 and 1.1 Professional 0 March 23rd, 2006 06:07 PM

All times are GMT -4. The time now is 06:54 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.