Bug #33754 | GetString can't handle nulls | ||
---|---|---|---|
Submitted: | 9 Jan 2008 2:32 | Modified: | 9 Jan 2008 19:32 |
Reporter: | Jared S (Silver Quality Contributor) | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / NET | Severity: | S1 (Critical) |
Version: | 5.1.4 | OS: | Windows (Any) |
Assigned to: | CPU Architecture: | Any | |
Tags: | getstring, nulls |
[9 Jan 2008 2:32]
Jared S
[9 Jan 2008 3:15]
Jared S
+S1 blocking issue
[9 Jan 2008 15:45]
Reggie Burnett
This is not a bug. The behavior is identical to SqlClient and is documented in the help file. It is designed this way to be consistent with the other GetXXX methods. It is impossible for methods like GetInt32 and GetFloat to return a null value to indicate that the column value is null so it would be inconsistent to allow GetString to do so. Also, returning '' to indicate a null value is a very bad idea since empty string is a non-null value and is a valid value for a string column. The correct behavior is the current behavior and that requires the user to either call GetValue (which will return DbNull.Value if the value is null) or call IsDBNull on the column to first check if the column is null.
[9 Jan 2008 19:32]
Jared S
Thank you, I will work around issue in code.