Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 2 of 2 total |
Casting vs. String.Format |
Wed, Jun 3 2009 4:44 PM | Permanent Link |
David Loving | MS VS 2008 C# code. ElevateDB version 2.2.13.0
I use DBDataReader to access a row of data from an ElevateDB database table. For most field datatypes, I can simply cast the returned object to the dataype I need such as (double)reader["fieldname"] or (int)reader["fieldname"] Strings don't work all the time. (string)reader["fieldname"] will error if the value in the table is null instead of an empty string. string.Format("{0}", reader["fieldname"]) will work with both null and empty strings in the table and return an empty string. Is this a bug in casting vs. formatting the return object from the ElevateDB library or another quirk in MS C# that makes ya go hmm...? |
Fri, Jun 5 2009 3:50 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | David,
<< Strings don't work all the time. (string)reader["fieldname"] will error if the value in the table is null instead of an empty string. >> But you don't get the error if an integer column is NULL ? Both should return an instance from System.Convert.DbNull that represents a NULL column value. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |