Why Does Executereader() Pad Strings With Traling Spaces?
I have two queries: Q1: select name from presidents where country = 'USA' Q2: select 'Obama' as name from presidents where country = 'USA' When using System.Data.Odbc.OdbcCommandE
Solution 1:
ExecuteReader returns data from the underlying data source without doing any padding.
It's your underlying data source, in this case Oracle, that is returning trailing spaces.
Google for "oracle trailing spaces" to understand why this is, and in particular to understand the difference between CHAR and VARCHAR data types in Oracle.
Meanwhile, you can either remove the trailing spaces in the SQL query:
SELECT RTRIM(Col1) FROM ...
Or remove them in the client:
string s = r.GetString(0).TrimEnd()
Post a Comment for "Why Does Executereader() Pad Strings With Traling Spaces?"