System.DBNull returned for whitespace strings
-
I am using OracleDataReader to read data from our DB (oracle) The annoying thing is that in a certain column I have a string with a single white-space, however the datareader seems to convert this to a System.DBNull value, which is incorrect. Does anyone know if there is a setting on the OracleDataReader or perhaps the OracleConnection objects to prevent the conversion from white-space strings to DBNull? Thanks for any help you can provide, Davy
-
I am using OracleDataReader to read data from our DB (oracle) The annoying thing is that in a certain column I have a string with a single white-space, however the datareader seems to convert this to a System.DBNull value, which is incorrect. Does anyone know if there is a setting on the OracleDataReader or perhaps the OracleConnection objects to prevent the conversion from white-space strings to DBNull? Thanks for any help you can provide, Davy
Are you sure that you really have a single whitespace in that column? Try running a select on the table where that column is null. In Oracle, if you insert a trimmed string and the string length is zero, it actually stores it as null.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Are you sure that you really have a single whitespace in that column? Try running a select on the table where that column is null. In Oracle, if you insert a trimmed string and the string length is zero, it actually stores it as null.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Ok, this was a really stupid mistake of mine. Had written a PL/SQL block that replaced for certain rows in particular cases a null value with a singe white space string. BUT here comes the stupidity : forgot to commit... Was running my .NET app: I got DBNull, was double checking on the session that had run the PL/SQL block which was returning ofcourse the single character string. So committed the changes now and runs like a charm. X|
-
Ok, this was a really stupid mistake of mine. Had written a PL/SQL block that replaced for certain rows in particular cases a null value with a singe white space string. BUT here comes the stupidity : forgot to commit... Was running my .NET app: I got DBNull, was double checking on the session that had run the PL/SQL block which was returning ofcourse the single character string. So committed the changes now and runs like a charm. X|
GDavy wrote:
forgot to commit...
Been there, seen it, got the T-shirt. Glad you got it sorted.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.