|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Nullable types and datareader...Hi all,
Nullable types were announced as new handy stuff in .NET 2.0 But it seems like the datareader doesn't support nullable types. You have still to check for "IsDbNull". So, are Nullable Types useful at this moment? Do you get any benefit using them (at this moment)? Is Microsoft going to change this? Best regards, Mobile Boy "MobileBoy36" <MobileBo***@gmail.com> wrote in I don't think DBNull and Null are the same thing - that's why Nullable news:457e7846$0$30037$ba620e4c@news.skynet.be: > Nullable types were announced as new handy stuff in .NET 2.0 > But it seems like the datareader doesn't support nullable types. > You have still to check for "IsDbNull". > So, are Nullable Types useful at this moment? Do you get any benefit > using them (at this moment)? > Is Microsoft going to change this? types are not directly converted. Take a look at LLBLGen Pro - it's a database framework from .NET. It has support for Nullable types and the like... and MORE :) Here's an example of using a nullable type. They are
good to use when you need to know if a number is 0 or Null, because those are two different things, especially if you are doing numerical calculations. Dim IntegerData As Nullable(Of Integer) If IntegerData.HasValue Then Console.WriteLine("IntegerData = " & IntegerData.ToString) Else Console.WriteLine("IntegerData = Null.") End If If you read data from a database, you have to check for DBNull and act accordingly. IntegerData = Nothing If NOT IsDBNull(myRow.ProductCode) Then IntegerData = myRow.ProductCode End If Another syntax for this is: If myRow.ProductCode IsNot DbNull.Value Then ... Robin S. ------------------------ Show quoteHide quote "MobileBoy36" <MobileBo***@gmail.com> wrote in message news:457e7846$0$30037$ba620e4c@news.skynet.be... > Hi all, > > Nullable types were announced as new handy stuff in .NET 2.0 > But it seems like the datareader doesn't support nullable types. > You have still to check for "IsDbNull". > So, are Nullable Types useful at this moment? Do you get any benefit > using them (at this moment)? > Is Microsoft going to change this? > > Best regards, > Mobile Boy > > Mobile Boy,
In addition to the other comments. I find nullable types to be very useful on my domain (business) objects. My data mappers (data objects) use DataReader.IsDBNull to decide if they need to return Nothing or a value for the nullable types on the domain objects. -- Show quoteHide quoteHope this helps Jay B. Harlow ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "MobileBoy36" <MobileBo***@gmail.com> wrote in message news:457e7846$0$30037$ba620e4c@news.skynet.be... > Hi all, > > Nullable types were announced as new handy stuff in .NET 2.0 > But it seems like the datareader doesn't support nullable types. > You have still to check for "IsDbNull". > So, are Nullable Types useful at this moment? Do you get any benefit using > them (at this moment)? > Is Microsoft going to change this? > > Best regards, > Mobile Boy > >
Multi-User Data App Architecture
Migrating to VS 2005 Error calling unmanaged DLL 11th hour failure to trigger click event for object in hash table Bring in a form from another solution/project Re: destroying/releasing objects from memory? Connected App (VB2005) Help... Problems with settings. Form Upload Test Utility? Trying to write a COM accessible DLL |
|||||||||||||||||||||||